##### Output of C program

if(<condition>)

print("hello");

else

print("world");

output: "hello world"

what is the condition?

Pritam Prasun 5 Dec 2014 09:09 pm

Condition is '!printf("hello ")'

So, the code is:

if(!printf("hello "))
printf("hello");
else
printf("world");

abhishek verma 6 Dec 2014 03:17 pm

awesome. (y)

jayendra 5 Dec 2014 09:19 pm

printf() function returns 0 or 1 and prints whatever is there between quotation marks.

Ranita Biswas 6 Dec 2014 10:11 am

printf() function actually returns the no. of characters successfully printed. So, in this case the printf() function in the condition returns 6 (for printing 'hello' and an appended space character). Any non-zero number is treated as TRUE, and it's negation gives us FALSE, so else part is being executed.

Vikash 7 Dec 2014 03:05 pm

thank you mam now i got actual concept of printf() .