Cpp Examples Sum Natural Number
# C++ Example - Sum of Natural Numbers
[ C++ Examples](#)
Calculate the sum of 1+2+3+....+n.
## Example
#includeusing namespace std; int main(){int n, sum = 0; cout<>n; for(int i = 1; i<= n; ++i){sum += i; }cout<<"Sum = "<<sum; return 0; }
The output of the above program is:
Enter a positive integer: 50Sum = 1275
[ C++ Examples](#)
YouTip