#WSQ04

WSQ04, the most challenging task so far (just kidding, they are all pretty easy. Even more if you have a friend’s help). Anyway, I’ll upload the video later, so you can see the whole process.

Code:

#include <iostream>
using namespace std;

int main()
{
int n1, n2, dif, sum, sum2, count=0, cicle;
cout<<endl;
cout<<“Give me two numbers and I’ll calculate the sum of the integer in that range.”<<endl;
cout<<endl;
cout<<“Please introduce the first number (the lower bound):”<<endl;
cin>>n1;
cout<<“Please introduce the second number (the upper bound):”<<endl;
cin>>n2;
dif=n2-n1;
cicle=dif;
sum=n1;
sum2=sum+1;
do
{
sum=sum+sum2;
sum2++;
count++;
}
while(cicle>count);
cout<<“The sum of the integers in that range is “<<sum<<“.”<<endl;
return 0;
}

Here’s the code working:wsq04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s