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

How much more does Rasheed need to earn before he can buy the video games? $3.85 $13.25 $15.25 $17.00
Please give me the correct answer.
Please Help me Please
PLEASE HELP DUE NOW will mark brainliest! 10 points
Which of the following ordered pairs would be the origin on a graph? A(0, -2) B(1,0) C(5,-5) D(0,0)
What is the probability that mr. Jackson will roll a 4 at least 5 times out of his 30 rolls of a number cube?
Peter and his four brothers combined all of their money to buy a video game. If 25% of the total money is Peter's, and $10.00 of the total money is Peter's, how
in a bag I have 16 yellow marbles, 14 by marbles and 10 black marbles. If I draw to marbles, one at a time, what’s my probability of drawing a black marble, put
A florist sold 16 flower bouquets yesterday, including 8 lily bouquets. Based on past data, how many of the next 10 bouquets sold should you expect to be lily b
cual es el diz mil mas cercano de 265,738​