ISDIGIT Function
-
How do I use the isdigit function my program won't compile. It says invalid operands of types `long double' and `' to binary `operator==' Here is my program //Calculator program #include #include using namespace std; int main () { long double var1; long double var2; char sign; //Begin calculator loop. Will loop continuously until first //number entered is a 0. do { cout << "Enter a number "; cin >> var1; cout << "Enter a sign "; cin >> sign; cout << "Enter a number "; cin >> var2; if(var1 == isdigit) continue; //Begin calculator functions. +, -, /, *. switch (sign){ case ('+'): cout << var1 + var2 << '\n' << '\n'; break; case ('-'): cout << var1 - var2 << '\n' << '\n'; break; case ('*'): cout << var1 * var2 << '\n' << '\n'; break; case ('/'): cout << var1 / var2 << '\n' << '\n'; break; default: cout << "You didn't enter a correct sign"; cout << '\n' << '\n'; break; //If the user enters an unrecognized sign they will get a //message that says: You ddn't enter a correct sign. } } while (var1 != 0); //If first number entered is a 0 //the program will terminate at the end //of the loop. (The Do While loop) } :confused:
-
How do I use the isdigit function my program won't compile. It says invalid operands of types `long double' and `' to binary `operator==' Here is my program //Calculator program #include #include using namespace std; int main () { long double var1; long double var2; char sign; //Begin calculator loop. Will loop continuously until first //number entered is a 0. do { cout << "Enter a number "; cin >> var1; cout << "Enter a sign "; cin >> sign; cout << "Enter a number "; cin >> var2; if(var1 == isdigit) continue; //Begin calculator functions. +, -, /, *. switch (sign){ case ('+'): cout << var1 + var2 << '\n' << '\n'; break; case ('-'): cout << var1 - var2 << '\n' << '\n'; break; case ('*'): cout << var1 * var2 << '\n' << '\n'; break; case ('/'): cout << var1 / var2 << '\n' << '\n'; break; default: cout << "You didn't enter a correct sign"; cout << '\n' << '\n'; break; //If the user enters an unrecognized sign they will get a //message that says: You ddn't enter a correct sign. } } while (var1 != 0); //If first number entered is a 0 //the program will terminate at the end //of the loop. (The Do While loop) } :confused: