0

Take input of three numbers and find largest number by using nested if condition.Is it correct??

#include <iostream> using namespace std; int main() { int x,y,z; cin>>x>>y>>z; if(x<z){ if(y<z){ cout<<"The largest number is "<< z; } } else{ cout<<"wrong"; } return 0; }

5th Dec 2023, 6:29 PM
Haram Abbas Lar
Haram Abbas Lar - avatar
9 Antworten
+ 2
Zoya Compare x with y and x with z If both returns true then x will be largest Otherwise compare y with z If y is greater than z then y is largest otherwise z is largest
5th Dec 2023, 7:01 PM
A͢J
A͢J - avatar
+ 1
What if x is greater than z output would be "wrong"?
5th Dec 2023, 6:32 PM
A͢J
A͢J - avatar
+ 1
Post in your existing thread. No need to create a new one. Duplicate https://www.sololearn.com/Discuss/3255101/?ref=app
5th Dec 2023, 6:44 PM
Lisa
Lisa - avatar
+ 1
Zoya There is \n, \t What about your above problem?
5th Dec 2023, 7:34 PM
A͢J
A͢J - avatar
0
Please explain i don't understand
5th Dec 2023, 6:33 PM
Haram Abbas Lar
Haram Abbas Lar - avatar
0
#include <iostream> using namespace std; int main() { int x,y,z; cin>>x>>y>>z; if(x>=y){ if(x>=z){ cout<<"largest number is "<<x; //cout<<"largest number is "<< y; } }else{ if(y>=x){ if(y>=z){ cout<<"largest number is "<<y; } } } if(z>=x){ if(z>=y){ cout<<"largest number is "<< z; } } return 0; }
5th Dec 2023, 7:00 PM
Haram Abbas Lar
Haram Abbas Lar - avatar
0
Is it right
5th Dec 2023, 7:00 PM
Haram Abbas Lar
Haram Abbas Lar - avatar
0
Why we use /n and /t
5th Dec 2023, 7:05 PM
Haram Abbas Lar
Haram Abbas Lar - avatar