Same code but shorter | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 5

Same code but shorter

#include <iostream> using namespace std; int main() {cout << "Hello world!" << endl << "I love programming!";}

10th Jan 2018, 9:51 AM
Arsham
Arsham - avatar
5 Answers
+ 2
4 answers and no one helped you... the shortest possible code for this is: #include <iostream> using namespace std; int main() { cout << "Hello World\nI love programming!"; }
10th Jan 2018, 11:01 AM
Konrad Błachowicz
Konrad Błachowicz - avatar
0
you changed the syntax, this code won't make any difference of compile time nor run time.
10th Jan 2018, 9:59 AM
Cain Eviatar
Cain Eviatar - avatar
- 1
but this code is easier to write ))
10th Jan 2018, 10:05 AM
Arsham
Arsham - avatar
- 1
this is a relative question. it's more comfortable to me to write it like this: #include <iostream> int main() { std::cout << "hello world" << std::endl; }
10th Jan 2018, 10:29 AM
Cain Eviatar
Cain Eviatar - avatar
- 1
Ahem. int main() { std::cout << "Hello World\n"; }
10th Jan 2018, 10:40 AM
BlazingMagpie
BlazingMagpie - avatar