Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's wrong with this program, it terminates?
    primarykey
    data
    text
    <p>The following program terminates after calculation selection and nothing happens further. So my question is what is wrong i'm doing? Kindly someone check this program and notify me my mistakes. This program is a calculator, which asks user to select the calculation method i.e addition, division or multiplicatio etc. and then shows the result after calculations Pic: <a href="http://i43.tinypic.com/2hykpjp.png" rel="nofollow">http://i43.tinypic.com/2hykpjp.png</a> Pardon me as i'm new to C programming.</p> <pre><code>main() { // declaration int add,sub,mul,div,selection; float a,b,c; // prompt user to select a method cout &lt;&lt; "Calculator, which performs addition,subtraction,multiplication and division: add,sub,mul,div"; cout &lt;&lt; "Please enter your selection (for example: mul): "; cin &gt;&gt; selection; if (selection = add) { // prompt user to enter values cout &lt;&lt; "Please enter first value: "; cin &gt;&gt; a; cout &lt;&lt; "Please enter second value: "; cin &gt;&gt; b; // calculations c = a + b; // result cout &lt;&lt; "Answer: " &lt;&lt; c; } if (selection == sub) { // prompt user to enter values cout &lt;&lt; "Please enter first value: "; cin &gt;&gt; a; cout &lt;&lt; "Please enter second value: "; cin &gt;&gt; b; // calculations c = a - b; // result cout &lt;&lt; "Answer: " &lt;&lt; c; } if (selection == mul) { // prompt user to enter values cout &lt;&lt; "Please enter first value: "; cin &gt;&gt; a; cout &lt;&lt; "Please enter second value: "; cin &gt;&gt; b; // calculations c = a * b; // result cout &lt;&lt; "Answer: " &lt;&lt; c; } if (selection == div) { // prompt user to enter values cout &lt;&lt; "Please enter first value: "; cin &gt;&gt; a; cout &lt;&lt; "Please enter second value: "; cin &gt;&gt; b; // calculations c = a / b; // result cout &lt;&lt; "Answer: " &lt;&lt; c; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload