Take input of three numbers and find largest number by using nested if condition.Is it correct?? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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 ответов
+ 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
+ 1
Assuming u don't especially need if else conditions to find out so https://sololearn.com/compiler-playground/ckMT6fk1UqWu/?ref=app
31st Dec 2023, 4:19 AM
Manuphile
Manuphile - 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