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

What is the LCm of two numbers if one number is a multiple of the other
who was Jamaica first national hero
How have traditional “explanations” of verbal behavior tended to delay a science of verbal behavior?
The formula for the area of a triangle is A = 1 2 bh, in which b represents the length of the base and h represents the height. If a triangle has an area of
A mechanic repairs Mr. Estes car the amount for parts is $48 and the rate for the mechanic is $40 per hour. Write and solve an equation to find the total cost o
which of the following is not an intensive physical property?A magnetism,B boiling point,C thermal conductivity,D volume
What features do all classical empires share? plz help i been trynna do this all night and i need a 2 short paragraphs please it would mean alot
Contamination of food items by other living organisms is know as
How do you distinguish one period from the next?
Please help!!!!!!!!!!!!!!!!!!!!