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 are examples of the discrimination that European Jews endured throughout history? Check all that apply.
An aquarium tank holds 65 gallons of water how much is in this in liters use the following conversion 1 gallon is 3.8 liters
Electricity is the movement of _____ from one atom to another along a conductor.
Determine the enthalpy of solution for a solid with δh values as described in each scenario.
Use the drop-down menus to put the plot events in order. Mr. Utterson and the *inspector find half a walking stick and a burnt checkbook. Mr. Hyde inexplicabl
Drag the correct label to the appropriate bin to identify the type of cartilage that forms each body structure.
What is the period in seconds of a simple pendulum of length 3 meters?
what is the main term for the following statement chronic pancreatitis
someone please help me with this problem ASAP SERIOUS ANSWERS ONLY!!!!!!!!!!!
Select the correct product of (x2 + 3)(x3 – 5)