Question

M 12 € → xc so we w t 607 Bral Co A ABC | Sigi 16 lobi indi | 7 Eng | T India Wol 1 Eng | log 17 san now C repl.it/student/su

C++ programming

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;
int CalSum(int v1,int v2)
{
int sum=0;
if(v1>v2)
{
int tmp=v2;
v2=v1;
v1=tmp;
}
for(int val=v1;val<=v2;++val)
sum+=val;
  
return sum;
}

int main()
{
int sum=0;
int v1,v2;
cout<<"please input two numbers:\n";
cin>>v1>>v2;
sum=CalSum(v1,v2);
cout<<"The sum of "<<v1<<" to "<<v2<<" is "<<sum<<endl;

return 0;
}

Add a comment
Know the answer?
Add Answer to:
C++ programming M 12 € → xc so we w t 607 Bral Co A ABC...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT