cout << " Enter first number : " << endl;
cin >> a;
cout << " enter the operation " << endl;
cin >> ope;
cout << " enter the second number " << endl;
cin >> b;
switch(ope) {
case '+' : c = a + b;
break;
case '-' : c = a - b;
break;
case '*' : c = a * b;
break;
case '/' : c = a / b;
break;
}
cout << " Result is : " << c << endl;
If someone can tell me how to repeat this program,and how to clear screen after every result ?
The goto statement can very quickly cause unreadable and un-debuggable spaghetti code. It should be avoided whenever possible which is pretty much always. The goto command is left-over from older languages before structured programming was created. It is really only used for fool-proof and immediate exits from very deeply nested loops.
It is MUCH better to just put you entire code in a large while(true) or for(;;) statement.