Monday 18 September 2017

How to write a program without using semicolon in C++?

As we know every line in C++ ends with the semicolon but we can print a string without using any semicolon in the program. we can print string by using if-else, looping or switch case but here I'm print a string with if-else without using the semicolon.

program to print a string without using any semicolon:-
#include<iostream>
using namespace std;
 main()
{
 if(cout<<"Hello World"){
 }
}
 output:-
Hello World

In the above, you see that there is no semicolon used in the program and also it is most frequently asked interview question.


0 comments:

Post a Comment