Without using semicolon print hello in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

Without using semicolon print hello in c++

in c++

15th Nov 2016, 3:51 PM
Pravin Pandit
Pravin Pandit - avatar
10 Answers
+ 7
Try putting the below code in the main function to print "Hello World..!" without using semicolon. while(!(cout<<"Hello world..!!!"<<endl)){} Looking forward for more inputs and clarifications if some one have.
15th Nov 2016, 4:03 PM
Pranjal Upadhyay
Pranjal Upadhyay - avatar
+ 6
if u r joking then "hello world..!" doesnt contain semicolon...!! so just print it out..! if not then, #include<iostream> void main(){ while(!(std::cout<<"Helloworld..!")) {} } In while loop there is "! " that means while loop will continue till there is false ans. in condition. but our condition is simple line, thats why it always returns " true". Hence it will break in first attempt. if there is no "!" then condition is true evry time and while loop will continue all the time for infinite iteration though it will also print helli world but infinite times.
15th Nov 2016, 7:51 PM
Jaydeep Galani
Jaydeep Galani - avatar
+ 4
#include<iostream int main(){ while(!(std::cout<<"hello")) {} }
15th Nov 2016, 11:56 PM
Krishna Hackster
Krishna Hackster - avatar
+ 2
A lot of fun here: The main question is how works if condition on cpp? The second info is related to syntax on cpp a joke to strongly typed language every single line is terminated by semicolon. But the dark side is strong on CodeLearn #include <iostream> int main() { if( std::cout << "Hello Baby" ){} }
3rd Jan 2017, 5:56 AM
nextco
nextco - avatar
+ 2
or... 1. Create a file contain the code you want.. including main() 2. Save the file with .h extention ( header) 3. Include that file in another .cpp file. 4. Compile and Run the .cpp 5. You are getting output just with the help of a header (without writing main() in cpp file) ヽ(^。^)ノ
3rd Jan 2017, 7:18 AM
Ayush Walekar
Ayush Walekar - avatar
+ 2
if(cout<<"hello world") this will work
3rd Jan 2017, 12:24 PM
Omkar Padir
Omkar Padir - avatar
+ 1
we can use the ASCII Numbers to print hello. just get the numbers and prints it in the form of characters using char data type.
3rd Jan 2017, 6:12 AM
Sudhanshu Kumar
Sudhanshu Kumar - avatar
0
#include <iostream> using namespace std; int main () { if(cout<<"Hello World"){} }
3rd Jan 2017, 6:20 AM
Vipray Jain
Vipray Jain - avatar
0
can anyone please help me get the logic behind this : if(cout<<"abc") or while(!(cout<<"abc")) : how are these printing without any semicolon??
30th Oct 2017, 4:32 AM
Mrinal Singh
Mrinal Singh - avatar
- 2
not possible
3rd Jan 2017, 6:27 PM
Kushal Patidar
Kushal Patidar - avatar