#include
void main(){
if(printf(“hello world”)){} // It prints the ?hello world? on the screen.
}
To print “hello world” without using a semicolon in a C program, you can use the \n
escape sequence to represent a newline character instead of a semicolon. Here’s the program:
c
int main() {
if (printf("hello world\n")) {
}
return 0;
}
In this program:
printf("hello world\n")
is used to print “hello world” followed by a newline character.- The
if
statement checks the return value ofprintf()
, which returns the number of characters printed. Since"hello world\n"
has more than 0 characters, theif
condition evaluates to true. However, the body of theif
statement is empty, so there’s no semicolon following theif
statement. - Finally,
return 0;
is used to indicate successful execution of the program.