Google Add

Search

Program to Print Hello World without using Semicolon - C, C++ Code

Write a C, C++ program to print hello world without using semicolon. In this tutorial, we are going to write a program which will print hello world using if-else, while and switch statements.

In c, c++ programming language every line ends with a semicolon, so it seems tricky how do you use printf  in C and cout in C++ without semicolon.


Programming Questions on Strings

How to read string with spaces using scanf

How to concatenate two strings


Program to Print Hello World without using semicolon



Print Hello World in C without using semicolon (;)

#include<stdio.h>


int main(void)
{

 if(printf("Hello World!"))  { }
 return 0;
}

Program to Print Hello World in C using Switch Statement


#include<stdio.h>
void main()
{
   switch(printf("Hello"))
   {
   }
}


Program to Print Hello World in C using While Statement


#include<stdio.h>
void main()
{
   while(printf("Hello"))
   {
   }
}

Program to Print Hello World in C++ Without Using Semicolon


#include <iostream>
using namespace std;

int main() {
 
 if(cout<<"Hello World!")  { }
 return 0;
}


This program doesn't contains any semicolon but still it works fine and prints the desired output. 




C, C++ Programs

1 comment: