How to add sentinel value in this program?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# include <iostream>
using namespace std;
int main()
{
char operation;
float num1,num2;
cout << "Enter operator either + or - or * or /: ";
cin >> operation;
cout << "Enter first operand: ";
cin >> num1;
cout << "Enter second operand: ";
cin >> num2;
switch(operation) 
{
case '+':
cout << num1+num2;
break;
case '-':
cout << num1-num2;
break;
case '*':
cout << num1*num2;
break;
case '/':
cout << num1/num2;
break;
default:

cout << "Error! operator is not correct";
break;
}

cout << endl; 
return 0;
}
Last edited on
Duplicate of http://www.cplusplus.com/forum/beginner/170490/

Please don't spam the forums with multiple threads on the same topic. It wastes peoples' time, and ultimately decreases the quality of the help you'll receive.

Also, please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

I don't understand what you mean by:

the lower case select another operation from the menu?


Can you elaborate?
Last edited on
I'am so sorry. I will not do it again.

how can I use it again, select another operation to use without running it again and again?

sorry for my English.
Topic archived. No new replies allowed.