Find sum of all 3 digit even numbers using while loop in Java
while Loop - Question 2
In this question, we will see how to find the sum of all 3 digit even numbers in Java programming using while loop. To know more about while loop click on the while loop lesson.
Q2) Write a program in Java to find the sum of all 3 digit even numbers using while loop.
Program
public class Q2
{
    public static void main(String args[])
    {
        int i=100,s=0;
        while(i<=999)
        {
            s=s+i;
            i=i+2;
        }
        System.out.println("Sum of all 3 digit even numbers = " + s);
    }
}Output
Sum of all 3 digit even numbers = 247050
