0

Take an input of three numbers and display larger number by using nested if condition . this program is correct??

#include <iostream> using namespace std; int main() { int x=4; int y=5; int z=6; if(x<6){ if(y<6){ cout<<"The larger number is "<< z; } else{ cout<<"wrong"; } } return 0; }

5th Dec 2023, 2:22 PM
Haram Abbas Lar
Haram Abbas Lar - avatar
3 Answers
+ 4
Zoya , Lisa already mentioned, that you should use the var `z` instead of a value of 6. > apart of this issue the code does not work properly. you should rework the logic for comparing the 3 variables.
5th Dec 2023, 3:33 PM
Lothar
Lothar - avatar
+ 3
1. Your code does not rake input. 2. You hard-coded the values 6 in your conditions – it should be z, not 6
5th Dec 2023, 3:25 PM
Lisa
Lisa - avatar
0
Find the larger number istead of display
5th Dec 2023, 2:23 PM
Haram Abbas Lar
Haram Abbas Lar - avatar