+ 1

What's wrong with my code. Why it doesn't work? I can't understand

https://code.sololearn.com/cmzLifu16DVO/?ref=app

4th Apr 2018, 1:37 PM
Poorie
Poorie - avatar
5 ответов
+ 18
/*logical error got caught ::: a>b and b<a are the same .... U must write b>a in place of b<a*/ //corrected code #include <iostream> using namespace std; int main() { int a,b; cout << "Put two numbers \n"; cin >> a >> b; cout << a << endl << b << endl; if (a>b) { cout << "Greatest is a"; } else if (b>a){ cout << "Greatest is b"; } else if (a==b){ cout << "a and b are equal"; } return 0; }
4th Apr 2018, 1:41 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 17
@Poorie //sometimes these errors occurs 😅 //I too have done and It is hard to catch such errors when lines in codes are large ... as they don't show what is the error at runtime , so we must view code again(or check each part by enclosing other in comments) .
4th Apr 2018, 1:53 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
a>b is same with b<a
4th Apr 2018, 1:43 PM
Bartosz Pieszko
Bartosz Pieszko - avatar
+ 1
Thank you for your answers guys! I can't believe, that i've done such a stupid fail.
4th Apr 2018, 1:48 PM
Poorie
Poorie - avatar
+ 1
Gaurav Agrawal That's true. Such a guileful trap!
4th Apr 2018, 1:56 PM
Poorie
Poorie - avatar