Programming Code Center(PCC)
[CPP]

(PCC)::[How-to-write-CPP-Program-to-Calculate-Sum-of-Natural-Numbers]::[cpp]

File Name : sum_of_Natural_Numbers.cpp

#include <iostream>
using namespace std;

int main()
{
    int n, sum = 0;

    cout << "Enter a positive integer: ";
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        sum += i;
    }

    cout << "Sum = " << sum;
    return 0;
}

Output :

sum_of_Natural_Numbers.jpg