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

Voy a cortar el césped __________ no voy a limpiar mi casa porque no tengo mucho tiempo. pero cuando si porque
PLEASE HELP!!!!Which of the following options is an equivalent function to f(x)=3(2)3x
In the early and mid-1800s, sectionalism was strongest in the West, where people felt their way of life depended on agriculture. in the West, where people were
En Costa Rica, se usa la frase 'pura vida' _____. as the name of a large plate of food that a wife would make for her husband as an expression to show a laid b
What adds more evidence to the idea that the cell is the basic unit of life?
_____ is a technique in which computers are designed with many microprocessors that work together, simultaneously, to solve problems.
When using a spreadsheet, sum in the expression =sum(b10:b16), is called a(n) ________?
Please help !! Image attached, will put most brainliest
Please help!! I attached an image, will give most brainliest
Which line from the first stanza of "The Second Coming" states the figurative problem that the speaker infers will initiate chaos? "Turning and turning in the