0
Someone can help me with this code?
The program return everytime number 2 no matter what value i introduced. https://code.sololearn.com/cwmsp0Y1G7nv/?ref=app https://code.sololearn.com/cwmsp0Y1G7nv/?ref=app https://code.sololearn.com/cwmsp0Y1G7nv/?ref=app
2 Answers
0
Hi, fix your comparison operator. Do it like this:
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
int x;
float f;
cin>>x;
if (x<0)
{
f=(x*2)-2;
}
else if(x==0)
{
f=3;
}
else
{
f=x+2;
}
cout<<f;
return 0;
}
0
After i changed the comparison operator the program works fine.
Thanks a lot.