65 744
Assignments Done
99,3%
Successfully Done
In October 2018

Answer to Question #16471 in C++ for Michael Rothermel

Question #16471
& Write a general summation program that allows the user to determine where it will begin and end, and what the increment shall be.
Expert's answer
#include<iostream>
using namespace std;

int b, e, i;

int sum(int b, int e, int i){
int res=0;
for (int k=b; k<=e; k++) res+=i;
return res;
}

void main(){
cout<<"enter the begin: ";
cin>>b;
cout<<"enter the end: ";
cin>>e;
cout<<"enter the increment: ";
cin>>i;

cout<<"sum = "<<sum(b,e,i)<<"\n";
system("PAUSE");
}

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions