Determine the if condition to print specific output

What should be the if condition in below code snippet, so that output would be “Hello World”.

 
 

Method 1: Using printf()

 

 
We can also use comma operator instead of depending upon the return value of printf in order to know what the conditional clause does.

 

Method 2: Recursive main()

 

 
Note that we can use write custom function instead of calling main() recursively –

 

 

 
References: http://stackoverflow.com/questions/33199/whats-the-condition-in-c-interview-test

 
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading...

Thanks for reading.

Please use our online compiler to post code in comments. To contribute, get in touch with us.
Like us? Please spread the word and help us grow. Happy coding 🙂
 



Leave a Reply

avatar
  Subscribe  
Notify of