+ 1
int num = 2; int x = 3; if(num >= 2) { if(x > 4) { num = 3; } else { num = 4; } } else {x = 1; }
Kyu iska answer lesson mea 4 bta rha hea Or normal mea no output please btao ear
11 odpowiedzi
+ 2
Sanskari Launda Gaming
num 2 hai to num >= 2 true hoga kynki 2 >= 2
So under jayega aur x > 4 check karega
ab x 3 diya hai to 3 > 4 false hoga to else me jayega
ab else me 4 num ko assign kar diya hai
Jab hum num ko print karenge to 4 aayega
+ 4
Sanskari Launda Gaming
No output bata raha hai kynki print nahi kiya hoga
Print num
cout << num; output will come.
+ 2
Yes output is 4
num >= 2 is true because num is given 2
but x > 4 false because x = 3 so num is 4 means output 4
+ 2
Sanskari Launda Gaming
Aisa isliye hai ki Aap ka Code toh Sahi hai aur lesson mein bataya hua iss Code ka Output bhi Sahi hai.
Lekin Apke Code mein Screen pr Output Value (jo num variable ki hai) print/display karnewala Command ya instruction likha nahi hai jo bahut jaroori hai, warna apko pata nahi chalega iss code ka output kya hai.
I fix Your Code in C programming, See and Run it below👇
https://code.sololearn.com/cWzI8rGtYnjp/?ref=app
Aap Yahi Corrected Code👆 C++ mein likh sakte hai, but aap printf() ke bajay c++ mein koi bhi valid Output Command use kijiye aur run kijiye aapko Output Value Screen pr Jaroor Dikhegi. 👍
I hope U will understand.😉
+ 1
Ok per screen mea ye code dala tuo "no output" output bta rha hea q ?
+ 1
Or elseea num =4 ye tuo puch rha hea na num=4 false hoga
+ 1
int num = 2;
int x = 3;
if(num >= 2) // condition is satisfied
{
if(x > 4) // condition failed
{
num = 3;
}
else // goes here
{
num = 4;
}
}
else // skipped part
{
x = 1;
}
// so ans will be
// x=3
// num =4
0
Ha sir ap shi ho per mea abhi bhi smja nahi kese 4 ayga
0
Is ka matlab ham int ki value if or else mea se change ker skte hea?
0
Aribato mjaimas you two rudra or aj muje samjane ke liye 😊😊❤
0
Answer 4