0

```
int main2()
{
cin.get();
cin.ignore();
cin.clear();
while(true)
{
long double x, y;
char ch_op;
Sleep(200);
cout << "Enter an expression below: \nExamples:\n";
cout << "x + y for Addition.\nx * y for Multiplication.\n" <<
"x / y for Division\nx - y for Subtraction.\nx & x for Square Roots.\n" <<
"x ^ y for Exponential Functions.\n\n";
cin >> x >> ch_op >> y;
switch(ch_op)
{
case '+':
{ add(x, y); main2(); break; }
case '-':
{ subtract(x, y); main2(); break; }
case '*':
{ multiply(x, y); main2(); break; }
case '/':
{ divide(x, y); main2(); break; }
case '&':
{cout << sqrt(x) << "\n\n"; break; }
}//switch
}//while
return 0;
}
int main(double z)
{
long double x, y;
char ch_op;
cout << "Enter an expression below: \nExamples:\n";
cout << "x + y for Addition.\nx * y for Multiplication.\n" <<
"x / y for Division\nx - y for Subtraction.\nx & x for Square Roots.\n" <<
"x ^ y for Exponential Functions.\n\n";
cin >> x >> ch_op >> y;
switch(ch_op)
{
case '+':
{ add(x, y); main2(); break; }
case '-':
{ subtract(x, y); main2(); break; }
case '*':
{ multiply(x, y); main2(); break; }
case '/':
{ divide(x, y); main2(); break; }
case '&':
{ cout << sqrt(x) << "\n\n"; main2(); break; }
default:
{ cout << "Invalid Entry. Returning to Main Menu";
Sleep(150); cout << ".";
Sleep(150); cout << " .";
Sleep(150); cout << " .";
main2();
break;
}
}//switch
return 0;
}
```

In the above code, if you enter something Invalid at the very beginning, the program goes back to main2(), but keeps displaying the menu over and over and over. Is this a problem with clearing the input stream? Because I tried inserting a cin.ignore(255, '\n') and that didn't help, nor did cin.clear() or cin.get()