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.
- C Program to print numbers from 1 to N without using semicolon?
- fork() in C
- How to write a running C code without main()?
- Commonly Asked C Programming Interview Questions | Set 1
- To find sum of two numbers without using any operator
- Program to compute Log n
- Print "Even" or "Odd" without using conditional statement
- Return values of printf() and scanf() in C/C++
- How will you show memory representation of C variables?
- What is the best way in C to convert a number to a string?
- Change/add only one character and print '*' exactly 20 times
- Implement Your Own sizeof
- Write a C program to print "Geeks for Geeks" without using a semicolon
- Program for Sum the digits of a given number
- How will you print numbers from 1 to 100 without using loop?