Computer Science, asked by ProGamerManthan1710, 14 hours ago

11. Write a Program (java) to print even numbers from N to 2 (N……….6, 4, 2)
hint n is the number accepted by the user and has to be even

Answers

Answered by srizaduttatig
0

Answer:

In the following example we are displaying the even numbers from 1 to n, the value of n we have set here is 100 so basically this program will print the even numbers between 1 to 100.

If an integer number(never a fraction number) is exactly divisible by 2 which means it yields no remainder when divided by 2 then it is an even number. This same logic we are using here to find the even numbers. We are looping through 1 to n and checking each value whether it is evenly divisible by 2 or not, if it is then we are displaying it. To understand this program you should have the basic knowledge of for loop in Java and if statement.

Similar questions