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

Which solution set is a solution for the following system? * -5x+y=-3 3x-8y=24 a. (0,-2) b. (3,-4) c. (0,-3) d. (2,3)
Which coupon will save Josiah more money on a crystal vase originally priced at $602.00? take 25% off or $150.00 off
HURRY ILL MARK YOU THE BRAINLEST The box plots below show the average daily temperatures in January and December for a U.S. city: two box plots shown. The top
A juggler is performing her act using several balls. She throws the balls up at an initial height of 4 feet, with a speed of 15 feet per second. This can be rep
Instead of the three dots, write a digit to make the fraction reducible. (Find all possible cases.) 77/... 333
Marquise's boyfriend is so he gets angry whenever Marquise spends time with friends instead of him.
affirmative tu command of agregar
art and crafts of muhajir
What is a result of the unequal electron sharing in a water molecule?
Can someone help me with this