Why we use ' endl ' at the end of every cout statement and return 0 at end of program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we use ' endl ' at the end of every cout statement and return 0 at end of program

27th Nov 2018, 11:29 AM
Sameer Ali
2 Answers
+ 2
endl isnt necesarry to be there, what it does is output a newline character the flush the output. Return 0 is part of standard, remember the function lesson where the function can return a data with type stated at function declaration. same with main function (int main()) it should return a value in int after the function. Why do we need it ? It simply tell if the program working correctly or not, if the value returned are 0, that means nothing is wrong.
27th Nov 2018, 11:35 AM
Taste
Taste - avatar
0
Thanks
28th Nov 2018, 7:35 AM
Sameer Ali