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

last one thank you to all the people that helped me out today
the advantages and disadvantages of mass media,the points are enuf pls help thx
The _______ is the most powerful body in the united nations.the _______ is the most powerful body in the united nations.
Maintaining eye contact is important when speaking as well as listening? True or false
Tate has a bag of golf balls. 3 red 5 blue 2 yellow 2 green. What is the probability that he pulls out a blue one?
What must occur for transcription to occur
How can u multiply a decimal
Solve for y. 2y - x = 3 4 (-y + 1) A) y = 4x + 3 B) y = 4x - 3 C) y = 4x + 3 11 D) y = 4x - 3 11
$4386 + 25% of the amount over $31850 1) 3986 2) 426.25 3) 4650 4) 7750
WILL BE MARKED BRAINLIEST PLEASE HELP!!!!!!!!! If the fifth and sixth terms of a geometric sequence are 8 and 16, respectively, then what is the first term?