I'm a c++ beginner . and im trying to build a program that will check if my float variable is float . then continue the program . but if not you will have to try again . thats what ive done for the moment .
while (true)
{
cout << "Okay, pick a number: " << flush;
cin >> num1;
}
idk how to build an if statement with my needings and need help from you guys.
im trying to make a calculator , by far my code is
float num1;
char continueQuestion;
float num2;
char op;
cout << "______________________________________________________" << endl;
cout << " " << endl;
cout << " Welcome to the amazing calculator! " << endl;
cout << "______________________________________________________" << endl;
while (true)
{
cout << "Would you like to continue? <y/n>: " << flush;
cin >> continueQuestion;
if (continueQuestion == 'y') {
break;
}
else if (continueQuestion == 'n')
{
exit(0);
}
else
{
cout << "That is not an answer!" << endl;
}
}
while (true)
{
cout << "Okay, pick a first number: " << flush;
cin >> num1;
}
and if you dont got it im trying to reach for an if statement that will check if my var num1 is not a float so print something . and i cant do that so i request help from you.