Home » Programming Tips & Tricks » C - Tips & Tricks

Different methods to print 'Hello world' without using semicolon in C

Submitted by Amit Shukla, on June 05, 2017

Learn: How to print any message like “Hello world” or how to execute a printf statement in C program without using semicolon.

This article contains some of the methods by using them you can execute any printf statement to print any message on the screen without using semicolon (which is a special character in C programming language and it is used to terminate the executable statement in C language)

1) Using if statement

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

2) Using loop statement

#include<stdio.h>
int main()
{
	while(!printf("Hello World"))
	{;}
	
	return 0;
}

3) Using switch statement

#include<stdio.h>
int main()
{
	switch(printf("Hello World"))
	{
	}
	
	return 0;
}

4) Using Macro Definition

#include<stdio.h>

#define a printf("Hello World")

int main()
{
    if(a){;}
	return 0;
}






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.