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