Skip to content

Instantly share code, notes, and snippets.

@samir96
Last active August 29, 2015 14:15
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 samir96/f69e9528a435be5cce56 to your computer and use it in GitHub Desktop.
Save samir96/f69e9528a435be5cce56 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main (){
int n1,n2, suma=0;
cout << "\nI will ask to you two numbers and I will sum all the number that are in that range"<<endl;
cout << "\n Please give me the lower bound: ";
cin>>n1;
cout << "\n Please give me the higher bound: ";
cin>>n2;
if(n1>n2){
cout << "\nThe lower number that you give me is not the lower, is higher than the second number."<<endl;
cout <<"\nTry to put the numbers in the correct order."<< endl;
}
else{
do{
suma=suma+n1;
n1=n1+1;
}while(n1<=n2);
cout <<"\nThe result of the sum is: " <<suma<<" "<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment