What is the problem in this code | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
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 Respuestas
+ 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