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!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.