Dremendo Tag Line

Find sum of all 3 digit even numbers using while loop in C++

while Loop - Question 2

In this question, we will see how to find the sum of all 3 digit even numbers in C++ programming using while loop. To know more about while loop click on the while loop lesson.

Q2) Write a program in C++ to find the sum of all 3 digit even numbers using while loop.

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int i=100,s=0;
    while(i<=999)
    {
        s=s+i;
        i=i+2;
    }
    cout<<"Sum of all 3 digit even numbers = "<<s;
    return 0;
}

Output

Sum of all 3 digit even numbers = 247050
video-poster