In this task I need to be able to make a program that can evaluate a range of numbers and make an operation (for example addition) so it will make a specific math equation like the following case:

if you give the programs the values of 1 and 10, it is going to interpret them like this: 1+2+3+4+5+6+7+8+9+10

At the begining and realizing what I was going to do I thought it was kind of difficult, but then Marco (a friend of mine) help me out with my code and the mistakes written inside the editor, until then I found a simpler way to make my program work.

Here are the results.

 <iostream>
 using namespace std;

 int main(){
  int sum=0;
  int x,y;

  int number=x;
  cout<<"This is a programm that can make the operation of addition in a range of values "<<endl;
  cout<<""<<endl;
  cout<<"Please give me the lower value ";
  cin>>x;

  cout<<"Please give me the upper value ";
  cin>>y;

  if (x>y){
  int temporal; //Store data, save data

  temporal=x;
  x=y;
  y=temporal;

  }

  for(int counter = x; counter <=y; counter++)

    sum += counter;

    cout<<"The result of the numbers from "<< x << " to "<<y<< " = "<< sum <<endl;

  return 0;


 }

CC BY 4.0 #WSQ07-Sum of numbers by Ever Ibarra Almaral is licensed under a Creative Commons Attribution 4.0 International License.