Welcome, %1$s. Please login or register.

November 22, 2017, 04:29:12 PM
: 1
: Tricky printf question  ( 3865 )
« : May 12, 2007, 12:24:34 AM From Shrinidhi»



Tricky printf question


if "condition"
        printf("Hello");
else
        printf("World");

What condition will make the program output "HelloWorld"



 
Liked It? Share it!

              


« #1 : May 12, 2007, 12:25:35 AM From Shrinidhi»

Condition -> !printf("Hello")

« #2 : May 12, 2007, 12:26:05 AM From Shrinidhi»

One more solution is to fork a task in the condition. This fork will return 2 values. The zero will print "World" and non-zero will print "Hello". However the order (HelloWorld or WorldHello) cannot be guaranteed.

« #3 : May 21, 2007, 01:11:28 AM From Sarbartha Sengupta»

if(printf("hello") && 0)
« #4 : November 22, 2007, 06:35:20 PM From iammilind»

One more,

if (1)
        printf("Hello");
else ;
        printf("World");

: 1
« previous next »

 

Best RatedList All>>



Latest
Random



SMF 2.0.10 | SMF © 2015, Simple Machines | Contact Webmaster | OnlineFunDb.com © 2009/10 | Legal Disclaimer