Computer Science, asked by spiritgaming38, 3 months ago

Write a program in Java to display all even numbers up to 100​

Answers

Answered by anindyaadhikari13
0

Answer:

This is the required Java program for the question.

public class EvenNum    {

   public static void main(String args[])  {

       for(int i=2;i<=100;i+=2)

           System.out.print(i+" ");

   }

}

Explanation:

  1. Line 1: Start of class.
  2. Line 2: Start of main() method.
  3. Line 3: Iterating a loop from i = 2 to 100 with condition - (i<=100), step value = 2
  4. Line 4: Display the value of i.
  5. Line 5: End of main().
  6. Line 6: End of class.

Refer to the attachment.

•••♪

Attachments:
Similar questions