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; }
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
+ 1
What if x is greater than z output would be "wrong"?
+ 1
Post in your existing thread. No need to create a new one.
Duplicate
https://www.sololearn.com/Discuss/3255101/?ref=app
+ 1
Zoya
There is \n, \t
What about your above problem?
0
Please explain i don't understand
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;
}
0
Is it right
0
Why we use /n
and
/t