Sanya Verma 67eb583af3 loops1
2022-09-27 18:39:26 +05:30

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;
}