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 do you remove a hard contact lens without pinching it?
what is 12=23????????
what were some of the interesting discoveries you have about our topic? about yourself?about others?
What are you checking for when you troubleshoot a circuit using voltage?
I will mark you as Brainlest if you can answer me this question correctly! Which animal undergoes complete metamorphosis? A: praying mantis B: termites C: gras
-2.4f + 0.4f - 13 - 5 simplified
What are the five categories of coverage in the marketplace under the PP ACA? a) Basic, Standard, Premium, Elite, Supreme b) Bronze, Silver, Gold, Platinum, Cat
Oliver uses 30 fruits to make a large batch of pineapple orange juice he uses five oranges for every one pineapple if he gets 2.5 fluid ounces of juice from eac
What type of facility advertises as providing care and supervision?a) Residential Care Facilityb) Restaurantc) Retail stored) Movie theater
What is the area of this parallelogram?