76 296
Assignments Done
Successfully Done
In May 2019

Answer to Question #17763 in C++ for apoorva

Question #17763
Write a C++ function to sum n natural numbers starting from a given number.
Expert's answer
#include <iostream>

using namespace std;

int sum(int N)
intS = 0;
for(inti = 0; i <= N; i++)
S+= i;

void main()
cout<< "Enter the number: ";
cin>> n;
cout<< sum(n) << endl;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions