Adsense 728 * 15

Search

Custom Search

Print Hello World without using Semicolon in C, C++

Write a C, C++ Program to print hello world without using semicolon. In this post i'll show how to print hello world in C, C++ using if-else, while and switch statements.

In C, C++ every line ends with semicolon, so it seems confusing how do you use printf  in C or cout in C++ function without semicolon.

Programming Questions on Strings.

How to read string with spaces using scanf

How to concatenate two strings.


Print Hello World in C without using semicolon (;)

#include<stdio.h>


void main()
{

 if(printf("Hello World!"))  { }

}

Print Hello World in C using Switch Statement


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


Print Hello World in C using While Statement


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

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 produces the desired output. 




C, C++ Programs

1 comment: