Swsan7715 Swsan7715
  • 03-06-2021
  • Computers and Technology
contestada

2- Write aC+ program that calculates the sum of all even numbers from [1000,2000], using the while loop.

Respuesta :

tonb
tonb tonb
  • 03-06-2021

Answer:

#include <iostream>

using namespace std;

int main() {  

 int n = 1000;

 int sum = 0;

 while(n <= 2000) {

   sum += n;

   n += 2;

 }

 cout << "sum of even numbers in [1000..2000] = " << sum << endl;

}

Explanation:

This will output:

sum of even numbers in [1000..2000] = 751500

Answer Link

Otras preguntas

___________________cm
As a block falls through the air by 40 meter it does work equal to -1800 joule. Determine the mass of a block.
please help and show work will be picking brainliest
how did supporters of the constitution convince opponents to approve it?
Help fast please Nosotros queremos que nuestros padres_______de fumar porque es malísimo para la salud. dejan dejaron degan dejen
You are charged with a crime in a very small, isolated town. You hire one of the two attorneys in town to defend you (the other one is his brother, the prosecut
All of the following are examples of whole foods except:
CAN SOMEONE PLEASE HELP
hello, anyhelp? if anybody likes they can answer, show work
can someone help me please? I don't understand what I need to do​