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.
- Count elements in a vector that match a target value or condition
- How to print a variable name in C?
- How to print % using printf()?
- How to Read and Print an Integer value in C++
- How to Read and Print an Integer value in C
- Print Hello World without semicolon in C/C++
- How will you print numbers from 1 to 100 without using loop? | Set-2
- Print 1 2 3 infinitely using threads in C
- Print calendar for a given year in C++
- How will you print numbers from 1 to 100 without using loop?
- Program to print last 10 lines
- Print 1 to 100 in C++, without loop and recursion
- Print "Even" or "Odd" without using conditional statement
- Print a long int in C using putchar() only
- How to print dimensions of multidimensional array in C++