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

30th Sep 2018, 5:24 AM
Joita Vladut
Joita Vladut - avatar
2 odpowiedzi
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; }
30th Sep 2018, 5:40 AM
Lance
Lance - avatar
0
After i changed the comparison operator the program works fine. Thanks a lot.
30th Sep 2018, 5:47 AM
Joita Vladut
Joita Vladut - avatar