### Help please

Hello everyone, can someone help me and tell why my program wont give me a result, I know Im using the do while-loop because the program is suppose to continue until user decides to exit, but I dont know why I cant get the result to display

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123`` ``````#include #include using namespace std; char again; void Values(double &num1, double &num2) { cout << "Please enter two numbers to calculate " << setprecision(5) << "\nNumber 1 "<> num1; cout <> num2; } void Addition(double &num1, double &num2, double &Result) { Result = num1 + num2; } void Subtraction(double &num1, double &num2, double &Result) { Result = num1 - num2; } void Multiplication(double &num1, double &num2, double &Result) { Result= num1 * num2; } void Division(double &num1, double &num2, double &Result) { if(num2 != 0) { setprecision(5); Result = num1 / num2; } else cout << "Please enter a number other than 0 as denominator"<> choice; } while (choice != 'E'); switch(choice) // Switch function allows user to choose the calculation to execute { case 'A': case 'a': Addition(num1, num2, Result); break; case 'S': case 's': Subtraction(num1, num2, Result); break; case 'M': case 'm': Multiplication(num1, num2, Result); break; case 'D': case 'd': Division(num1, num2, Result); break; default: case 'E': case'e': cout << "E - Exit Program" << endl << endl; exit(0); cout << "Please enter a valid menu choice from above: "; cin >> choice; break; } system("PAUSE"); return 0; }``````
The program cannot read your mind, you have to tell it to display the value of Result.

Line 102 and 103 do no make sense inside that default case. Lines 109 - 111 belong with the default case and lines 104 and 105 belong with cases "E" and "e"

Lines 84 - 115 are supposed to be inside the do-while loop

EDIT: Do not double post http://www.cplusplus.com/forum/beginner/108052/
Last edited on
thanks, sorry I didnt I wasnt suppose to.

I was wondering why is it that when I input 0 for number 2 I get a display of "Please enter a number other than 0 as denominator result is 3"

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102`` ``````#include #include using namespace std; void Values(double &num1, double &num2) { cout << "Please enter two numbers to calculate; " << setprecision(5) << "\nNumber 1 " <> num1; cout <> num2; } void Addition(double &num1, double &num2, double &Result) // Function used to calculate sum { Result = num1 + num2; } void Subtraction(double &num1, double &num2, double &Result) { Result = num1 - num2; } void Multiplication(double &num1, double &num2, double &Result) { Result= num1 * num2; } void Division(double &num1, double &num2, double &Result) // Function used to calculate quotient { if(num2 != 0) { setprecision(5); Result = num1 / num2; } else cout << "Please enter a number other than 0 as denominator"; } int main() { char choice; double num1,num2, Result; do { Values(num1, num2); cout << endl << endl << "Table of Operations" << endl; cout << "A -- Addition" << endl; cout << "B -- Subtraction" << endl; cout << "C -- Multiplication" << endl; cout << "D -- Division" << endl; cout << "E -- Exit" <> choice; switch(choice) // Switch function allows user to choose the calculation to execute { case 'A': case 'a': Addition(num1, num2, Result); break; case 'B': case 'b': Subtraction(num1, num2, Result); break; case 'C': case 'c': Multiplication(num1, num2, Result); break; case 'D': case 'd': Division(num1, num2, Result); break; default: case 'E': case'e': cout << "E - Exit Program" << endl << endl; exit(0); } { cout << "result is " << Result <

 ``123456789`` `````` case 'D': case 'd': while(num2 == 0) { cout << "Please enter a number other than 0 as denominator"; cin>>num2; } Division(num1, num2, Result); break;``````

Remove if else statement in ur divison function.
Also u should prompt for choice of operation first, then ask for input.
Topic archived. No new replies allowed.