Is there any problem with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there any problem with this code?

#include <iostream> using namespace std; int main() { /* Comment out printing of Hello world! cout << "Hello world!"; // prints Hello world! */ return 0; }

31st Oct 2016, 8:04 AM
Ehtisham Ahmad
Ehtisham Ahmad - avatar
4 Answers
+ 1
Yup, /* is a multi-line comment, it ends whenever it sees */. They might seem useless now, but comments are extremely useful. Use them around your code to explain what it does, because in the future you might forget when you come back and look at it. Happy coding!
2nd Jan 2017, 6:04 PM
Ramel Mammo
Ramel Mammo - avatar
0
I don't see a problem, but this won't run anything since you commented out all the code within main() (not sure if you meant to do that). main() will be called, and right away will return 0;
31st Oct 2016, 8:09 AM
Ramel Mammo
Ramel Mammo - avatar
0
Yeag actually it's in the lesson. I clicked on "Try it yourself" and it said "No Output". Just wondering why it's like this and included as a verified code...
31st Oct 2016, 8:11 AM
Ehtisham Ahmad
Ehtisham Ahmad - avatar
0
Got it bro. The lesson meant that the whatever is in the comment, will be ignored. I changed the code to #include <iostream> using namespace std; int main() { /* Comment out printing of Hello world! */ cout << "Hello world!"; // prints Hello world! return 0; } and it worked. Cheers 🍻
31st Oct 2016, 8:17 AM
Ehtisham Ahmad
Ehtisham Ahmad - avatar