What should be the “condition” so that the following code snippet prints both HelloWorld!
if "condition" printf ("Hello"); else printf("World");
Explanation: Printf returns the number of character it has printed successfully. So, following solutions will also work
if (printf(“Hello”) < 0) or if (printf("Hello") < 1) etc
Method 2: Using fork()
This method is contributed by Aravind Alapati.
Please comment if you find more solutions of this.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.