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

es el sodio bueno para la salud?
In both Egypt and Mesopotamia, who occupied the lowest social class? HELP ASAP
List the causes of World War I and the war's effects on social, economic, and foreign policy in the United States?
the scores of several classmates on a math test are shown below: 91 points 77 points 90 points 79 points 81 points 85 points 86 points 76 points 75 points 80 po
hey can anybody help me out with this please
Line cd contains points a(4,-7)and b(4,8). The slope of the line cd is
help please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20 POINTS help me with this question please Simplify the rational expressions. State any excluded values. Show your work x - 2/ x^2 + 3x - 10
(2-2)(34 (2-3)(32)2?2,(34-3va2Which is the simplified form of the expression023534836 48230 30-80236348(30000
This is a college program that prepares students to become officers in the U.S. Military. In exchange for a paid college education students commit to serve in t