comparison is always false due to limited range of data type

When i use this code:

#include <iostream>
#include <math.h>
#include <stdio.h>*/
using namespace std;


int main ()
{
double a;
double c;
char oper;
cout << "enter the first number" << endl;
cin >> a;
cout << "enter the operation (+ - / * sqrt)" << endl;
cin >> oper;

if (oper == 'sqrt') { //warning line FALSE one
cout << sqrt(a) << endl;
sleep(5);
exit(0);

}
if (oper != 'sqrt') { //warning line TRUE one

cout << "enter the second number " << endl;
cin >> c;

if (oper == '+') {
cout << "the answer is " << a+c << endl;
}
if (oper == '-') {
cout << "the answer is " << a-c << endl;
}
if (oper == '*') {
cout << "the answer is " << a*c << endl;
}
if (oper == '/') {
cout << "the answer is " << a/c << endl;
}
sleep(5);
return 0;
}
}

it tells me "comparison is always TRUE due to limited range of data type"
or "comparison is always TRUE due to limited range of data type"
char is a SINGLE character, not a string. Use std::string for that.
where am i supposed to insert that
Just replace char with string at char oper.
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;


int main ()
{
double a;
double c;
//std::string
string oper;
cout << "enter the first number" << endl;
cin >> a;
cout << "enter the operation (+ - / * sqrt)" << endl;
cin >> oper;

if (oper == 'sqrt') {
cout << sqrt(a) << endl;
sleep(5);
exit(0);

}
else {

cout << "enter the second number " << endl;
cin >> c;

if (oper == '+') {
cout << "the answer is " << a+c << endl;
}
if (oper == '-') {
cout << "the answer is " << a-c << endl;
}
if (oper == '*') {
cout << "the answer is " << a*c << endl;
}
if (oper == '/') {
cout << "the answer is " << a/c << endl;
}
sleep(5);
return 0;
}
}

now I have even more errors
When you use strings, it can hold actual words. So you need to put quotes around anything you compare them to.

Ex:
1
2
3
string oper;
//oper is a string, so you need to compare it to another string ("Quotes")
if(oper == "+")
thank you that works but I have one more question
when the answer is a large nuumber it becomes something like 5.7648e+06 how to I fix this
o i did not notice that that was in scientific notation
Topic archived. No new replies allowed.