#Mastery07 #TC1017

In c++ use of comments it´s fundamental for the programer. It´s used for but some relevants comments of the programm and one characterist of the comments is that won´t appear while the code it´s running.

Code:

<iostream>

using namespace std;

 

int main ()

{

int L,U; //se declaran las constantes dentro de la funcion principal

char A; //se declara una “char” para despues poder obtener una respuesta del usuario

 

  do //loop para repeticion del programa

  {

    cout << “We will calculate the sum of integers in an specific range:  ” << endl;

    cout << “Lower bound of the range: “<< endl;

    cin >>L; //aqui se guarda el limite inferior

    cout << “Upper bound of the range: “<< endl;

    cin >> U;//se guarda el limite superior

    int suma=0; //se declara la sumatoria inicial en 0

    for (int i=L; i<U; i++) //loop para hacer la sumatoria de los numeros

    {

 

      suma = suma + i;

      i++;//i incrementa de uno en uno

 

    }

    cout << “The sum of the range given is: ” << suma << endl;

    cout << “Would you like to repeat the program?  (Y) (N)” << endl;

    cin >> A; //se guarda la respuesta del usuario…repetir o no.

    } while (A ==’Y’);

return 0;

}

 

CC BY 4.0 #Mastery07 #TC1017 by Pablo Guerra is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.