mirror of
https://github.com/federico-busato/Modern-CPP-Programming.git
synced 2025-04-20 00:19:03 +03:00
16 lines
306 B
C++
16 lines
306 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int n;
|
|
cout << "Enter the value of n : ";
|
|
|
|
cin >> n;
|
|
int sum = 0;
|
|
for (int i = 1; i <= n; i++)
|
|
{
|
|
sum += i;
|
|
}
|
|
cout << "\n The sum of first " << n << " natural numbers is ---> " << sum << endl;
|
|
return 0;
|
|
} |