Last active
August 29, 2015 14:15
-
-
Save samir96/f69e9528a435be5cce56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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