Home > Backend Development > C++ > C program prints 'Hello World!' without using semicolon

C program prints 'Hello World!' without using semicolon

PHPz
Release: 2023-09-14 11:25:04
forward
714 people have browsed it

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")) {
   }
}
Copy after login

Output

Hello World
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template