Calculate the sum of n natural no using do while loop in c++
Answers
Answered by
0
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;
}
Hope it helps...... Please mark it as brainliest......
jitendrajaya123:
Please mark it as brainliest....
Similar questions