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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Count elements in a vector that match a target value or condition
- How to print % using printf()?
- How to print a variable name in C?
- How will you print numbers from 1 to 100 without using loop? | Set-2
- Print 1 to 100 in C++, without loop and recursion
- Program to print last 10 lines
- How will you print numbers from 1 to 100 without using loop?
- Print "Even" or "Odd" without using conditional statement
- How to Read and Print an Integer value in C
- How to Read and Print an Integer value in C++
- Print 1 2 3 infinitely using threads in C
- C++ program to print all Even and Odd numbers from 1 to N
- Print calendar for a given year in C++
- Print Hello World without semicolon in C/C++
- Print a long int in C using putchar() only
- How to print N times without using loops or recursion ?
- How to print dimensions of multidimensional array in C++
- C++ Program to print an Array using Recursion
- C++ Program to Print Cross or X Pattern
- Program to print Happy Birthday