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
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.