why sum is line is included in this program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why sum is line is included in this program

why sum is used. why cout<<sum directly not used like previous example and why endl used

14th Jul 2016, 6:32 PM
Khan Zeeshan
Khan Zeeshan - avatar
1 Answer
+ 3
because cout << sum; wouldn't end with a new line and something u want to print after that command would be printed right after the sum output. while cout << sum << endl; tells the Compiler to do a new line break. the First cout is commonly used to print the output of loops in a row, where the endl; Statement is following after the loop has been left.
14th Jul 2016, 7:35 PM
Steven
Steven - avatar