C++ Program to print sum of first 10 natural numbers


In this program, You will learn how to print sum of first 10 natural numbers in C++.


1 + 2 + 3 + ... + 10 = 55


Example: How to print sum of first 10 natural numbers in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int i, s = 0;

    for (i = 1; i <= 10; i++) {
        s = s + i;
    }
    cout << "Sum of First 10 Natural Numbers is :" << s;

    return 0;
}

Output:

Sum of First 10 Natural Numbers is :55