0

What is the problem in this code

#include <iostream> using namespace std; int main() { int a,b,c; cout<<"enter three numbers:"; cin>>a>>b>>c; if (a>b&&a>c) cout<<"\n biggest number is "<<a; else if (b>a && a>c) cout<<"\n biggest number is"<<b; else cout<<"\n biggest number is "<<c; return 0; }

4th Mar 2022, 2:37 PM
muhammed yaseen
muhammed yaseen - avatar
4 Answers
+ 3
Check for the following values of a, b and c a = 2 b = 3 c = 2 Expected o/p = biggest number is 3 O/p generated by your program = biggest number is 2
4th Mar 2022, 2:41 PM
Arsenic
Arsenic - avatar
+ 2
Working fine no problem
4th Mar 2022, 2:39 PM
AÍąJ
AÍąJ - avatar
+ 2
It will fail for certain cases. else if (b>a && b>c) The above line should be changed to b>c as mentioned.
4th Mar 2022, 2:42 PM
Avinesh
Avinesh - avatar
+ 1
Tnx
4th Mar 2022, 2:43 PM
muhammed yaseen
muhammed yaseen - avatar