why output is 123??? | SoloLearn: Learn to code for FREE!

+6

why output is 123???

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

c if

5/27/2020 10:26:32 AM

Ashutosh k.

8 Answers

New Answer

+4

Ashutosh k. If the Boolean expression evaluates to true, then the block of code inside the 'if' statement will be executed. Here the Boolean expression evaluates to false, then the first set of code after the end of the 'if' statement will be executed. So it printed 123 It will raise error as 2 conditions are passed in if statement separated by comma

+4

𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 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, 👍👍👍👍👍👍👍👍👍

+4

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

+3

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

+3

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

+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

+2

Raj Kalash Tiwari Plz use Google Translate app to convert your language in English If you answer in English, it will be helpful for other users so that they can convert the answer in own language

+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