+ 7

why output is 123???

#include <stdio.h> int main() { if(0>1,2>21) printf("hello"); printf("123"); return 0; }

27th May 2020, 10:26 AM
Ashutosh k.
Ashutosh k. - avatar
8 Answers
+ 5
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 sorry i used slag language as i knew that this person understands this language, and no worries from next time i will use proper English, 👍👍👍👍👍👍👍👍👍
28th May 2020, 4:39 AM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 5
If the 'if' condition was true it would print both since it's not it moved to the next set of code and prints 123
28th May 2020, 6:21 PM
Mehnaz ✨
Mehnaz ✨ - avatar
+ 4
Bhai 1st expression if just baad wali execute nahi hogi as , if to false ho gaya hai, then 2nd Printf("123"); Hi run hoga na answer 123
28th May 2020, 1:54 AM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 4
Bro, 1st expression just after if statement will not be executed, as condition of inside if is false and then 2nd expression i.e. printf("123") will be executed and will produce answer, 123
28th May 2020, 4:38 AM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 3
Here your if condition is working as or operator means if one condition is true then first printf will be execute . If(0>1,2<21) then here (2<21)its also True then first printf will be execute. Here in your case your both condition are false before comma and after comma so second printf will be execute and answer is 123
29th May 2020, 9:10 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Hi, Because Condition of If was false. and next statement is print so it will print 123 This code is as below: if(0>1,2>21) //Condition false { printf("hello"); } //terminate this loop and execute next statement printf("123"); so output is 123
28th May 2020, 7:32 AM
AjayGohil