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

Correct answer will get brainliest and full ratings.
What is the answer to a line GH passes through points (2,5) and (6,9). Wich equation represents line GH
How many ml of a 14.0 m nh3 stock solution are needed to prepare 200 ml of a 4.20 m dilute nh3 solution? hints how many ml of a 14.0 m stock solution are needed
What was the Reconquista?
What is the inverse of the given function? y = 7x2 -­ 3?
The hospital shop buys cereal bars in boxes of 4. In one day they sell 58 individual cereal bars. How many boxes of cereal bars did they open that day?
After reading the brochure, you could conclude that the history of Ghost Ranch is heavily influenced by
What is the highest legal authority in the United States government? a.the PresidentB)U.S. ConstitutionC)the Supreme CourtD)state constitutions
How much is 4% of 2000.00
Charles was the last person on his block to purchase a color television set, and that was in the 1980s. he just couldn't see the reason to purchase a new color