C++ program to Find Sum of Natural Numbers - KhurafatiTech How to Tips-Tricks

Recent

Tuesday, August 28, 2018

C++ program to Find Sum of Natural Numbers

download C++ source code file
Here I am using "do - while" loop.
we use loop, when we need to repeat an statement and we know the condition , to which we want to repeat that statement. we can also use "for " loop here. "for " loop used when we know , how many times the statement is to be repeated.
the "do-while" loop works as:

body of the loop(statements) is always executed first.  Then, the test condition is evaluated.  If the test condition is TRUE, the program executes the body of the loop again.  If the test condition is FALSE, the loop terminates and program execution continues with the statement following the while.

No comments: