Computer Science, asked by dhfgduydi857, 1 year ago

Write a program in c++ to find the sum of s=1+2+3+4+....Up to nth term

Answers

Answered by AdityaRenukdas
1

#include<iostream>

void main()

{

int n, i, s;

s = 0;

cout << "Enter a number" << "\n";

cin >> n;

for(i = 1; i <= n; i++)

{

s = s + i;

}

cout << "The answer is: " << s << "\n";

}

Similar questions