This is my code. Anyone who can solve the problem? Okay, it seems it works anyway, the warning message is just displayed when I compile, but does not stop me from compiling or running the program.
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <iostream.h>
- int main()
- {
- float num1;
- float num2;
- int num3;
- float num4;
- cout << "Enter a number." << endl;
- cin >> num1;
- cout << "Enter a second number." << endl;
- cin >> num2;
- if (num1 == 0 || num2 == 0)
- {
- {
- cout << "Choose an operation." << endl;
- cout << "Type 1 to add, 2 to subtract or 3 to multiply." << endl;
- cin >> num3;
- }
- if (num3 >3 || num3 <1)
- {
- cout << "You operation choice isn't valid! Please run the program again." << endl;
- cout << "Press Enter to end the proogram." << endl;
- getchar();
- return 0;
- }
- else
- {
- if (num3 == 1)
- {
- num4 = num1 + num2;
- cout << "Result is: "<< num4<< endl;
- }
- else if (num3 == 2)
- {
- num4 = num1 - num2;
- cout << "Result is: "<< num4<< endl;
- }
- else if (num3 == 3)
- {
- num4 = num1 * num2;
- cout << "Result is: "<< num4<< endl;
- }
- }
- }
- cout << "Press Enter to end the program." << endl;
- getchar();
- return 0;
- if (num1 != 0 || num2 !=0)
- {
- {
- cout << "Choose an operation." << endl;
- cout << "Type 1 to add, 2 to subtract, 3 to multiply or 4 to divide." << endl;
- cin >> num3;
- }
- if (num3 >4 || num3 <1)
- {
- cout << "You operation choice isn't valid! Please run the program again." << endl;
- cout << "Press Enter to end the proogram." << endl;
- getchar();
- return 0;
- }
- }
- else
- {
- if (num3 == 1)
- {
- num4 = num1 + num2;
- cout << "Result is: "<< num4<< endl;
- }
- else if (num3 == 2)
- {
- num4 = num1 - num2;
- cout << "Result is: "<< num4<< endl;
- }
- else if (num3 == 3)
- {
- num4 = num1 * num2;
- cout << "Result is: "<< num4<< endl;
- }
- else if (num3 == 4)
- {
- num4 = num1 / num2;
- cout << "Result is: "<< num4<< endl;
- }
- }
- cout << "Press Enter to end the program." << endl;
- getchar();
- return 0;
- }