C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

Write a program to print "Hello World" without using semicolon anywhere in the code inC?

0 votes
156 views
asked Jan 8, 2014 by keem Expert (13,240 points)

1 Answer

0 votes
Generally when we use printf("") statement, we have to use a semicolon at the end. If printf is used inside an if condition, semicolon can be avoided.

Program: Program to print some thing with out using semicolon(;)

#include <stdio.h>

int main() {

//printf returns the length of string being printed

if (printf("Hello World\n")) //prints Hello World and returns 11

{

//do nothing

}

return 0;

}

Output:

Hello World

Explanation:

The if statement checks for condition whether the return value of printf("Hello World") is greater than

0. Printf function returns the length of the string printed. Hence the statement if (printf("Hello World"))

prints the string "Hello World".
answered Jan 8, 2014 by rajesh Guru (39,140 points)

Related questions

+4 votes
2 answers 467 views
0 votes
1 answer 45 views
0 votes
2 answers 108 views
0 votes
1 answer 1,526 views
...