#include <iostream>
usingnamespace std;
int main()
{
char n;
do
{
char input = ' ';
int num1, num2, sum, difference, product, quotient = 0;
cout << "Enter number 1 ";
cin >> num1;
cout << "Enter number 2 ";
cin >> num2;
cout << "Choose arithmetic process " << endl;
cout << " A for add ";
cout << " S for subtract ";
cout << " M for multiply ";
cout << " D for divide ";
cin >> input;
switch (input)
{
case'A': case'a':
sum = num1 + num2;
cout << "The sum is " << sum << endl;
break;
case'S': case's':
difference = num1 - num2;
cout << " The difference is " << difference << endl;
break;
case'M': case'm':
product = num1 * num2;
cout << " The product is " <<product << endl;
break;
case'D': case'd':
quotient = num1 / num2;
cout << "The quotient is " << quotient << endl;
break;
}
cout << " try again? (y/n)" << endl;
cin >> n;
} while(n != 'n' && n != 'N');
cout << endl;
return 0;
}
There you go. :) All you needed to do was change the do-while loops condition to n != 'n' && n != 'N'. That's just saying, run the loop while n is not equal to 'n' andn is not equal to 'N'. If it's anything other than that, the loop will 'loop' back to the top.