How to print "Hello World" without using a semicolon in the whole program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to print "Hello World" without using a semicolon in the whole program?

Print "Hello World" without using a semicolon in the whole c++ program

14th Jan 2018, 10:27 AM
Adarsh Pathak
Adarsh Pathak - avatar
22 Answers
+ 6
#include<iostream> main(){ if(std::cout<<"hello") { } } use this code now it works
14th Jan 2018, 10:51 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 4
I see I need to put on my hacker hat on. See you in a few hours. Edit: guess I won't have to do anything because Mayur Chaudhari nailed it.
14th Jan 2018, 10:31 AM
BlazingMagpie
BlazingMagpie - avatar
+ 3
if(cout<<Hello world){ } //in if condition everything is accepted as true except 0 0 is consider as false
14th Jan 2018, 10:35 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 3
@Blue I asked to ans it in c++
14th Jan 2018, 10:40 AM
Adarsh Pathak
Adarsh Pathak - avatar
+ 3
@Adarsh Pathak It's just a fragment, full code would be #include <iostream> int main(){ if(std::cout<<"Hello World!"){} }
14th Jan 2018, 10:42 AM
BlazingMagpie
BlazingMagpie - avatar
+ 3
If u use int as a return type for main u need to use return 0; compulsorily which includes a semicolon
14th Jan 2018, 10:44 AM
Adarsh Pathak
Adarsh Pathak - avatar
+ 3
now see my code use only main() not need to use return 0; it take main() by default data type is int
14th Jan 2018, 10:47 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
@Mayur Chaudhari the given code isn't executable.
14th Jan 2018, 10:38 AM
Adarsh Pathak
Adarsh Pathak - avatar
+ 2
use it as
14th Jan 2018, 10:39 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
#include<iostream> int main(){ if(cout<<"hello) { } }
14th Jan 2018, 10:40 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
wait i am share you code link
14th Jan 2018, 10:41 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
N if u use void instead of int ur concept of if won't work@Mayur Chaudhari
14th Jan 2018, 10:44 AM
Adarsh Pathak
Adarsh Pathak - avatar
14th Jan 2018, 10:44 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
U used a semicolon buddy
14th Jan 2018, 10:46 AM
Adarsh Pathak
Adarsh Pathak - avatar
+ 2
N if u use void instead of int ur concept of if won't work@Mayur Chaudhari
14th Jan 2018, 10:46 AM
Adarsh Pathak
Adarsh Pathak - avatar
+ 2
You don't really have to use return in main in some compilers, like in SoloLearn's one.
14th Jan 2018, 10:47 AM
BlazingMagpie
BlazingMagpie - avatar
+ 2
it work now see it plz
14th Jan 2018, 10:48 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 2
I'd give a credit to you if your work wasn't so sloppy. using namespace std;
14th Jan 2018, 10:50 AM
BlazingMagpie
BlazingMagpie - avatar
+ 2
Awesome work @Mayur Chaudhari!!!
14th Jan 2018, 10:53 AM
Adarsh Pathak
Adarsh Pathak - avatar
+ 2
Nice to see we arrived back at the solution we were 10 minutes ago.
14th Jan 2018, 10:55 AM
BlazingMagpie
BlazingMagpie - avatar