Skip to content

Instantly share code, notes, and snippets.

@alonzoibarra97
Created February 16, 2016 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alonzoibarra97/cb40a5ecea0a61c9f1d3 to your computer and use it in GitHub Desktop.
Save alonzoibarra97/cb40a5ecea0a61c9f1d3 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main(){
int n1, n2;
cout << "We will calculate the sum of integers in the range you provide.\n";
cout<< "Please give us the lower bound: \n";
cin>> n1;
cout<< "Please give us the upper bound: \n";
cin>> n2;
int c= n1;
int sum=0;
do{
sum=sum+c;
c=c+1;
}while(c<=n2);
cout << "The sum from " << n1 << " to " << n2 << "is " << sum;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment