Home  >  Article  >  Backend Development  >  C program prints "Hello World!" without using semicolon

C program prints "Hello World!" without using semicolon

PHPz
PHPzforward
2023-09-14 11:25:04690browse

C程序打印“Hello World!”而不使用分号

Let us see how to write a C program in which we can print the text "Hello World" without using any Text can be written simply by using printf("Hello World") in the main function. But there is a semicolon at the end of the line. To avoid semicolons we can use some tricks The same printf() statement can be used in an if conditional statement. Since the printf() statement returns the length, you can do text, so it is non-zero and therefore the if statement will be true. So the text will be written in Translation: The length of the text is non-zero, so the if statement will be true. So the text will be written screen.

Sample code

#include<stdio.h>
main() {
   if(printf("Hello World")) {
   }
}

Output

Hello World

The above is the detailed content of C program prints "Hello World!" without using semicolon. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete