Write a program in Java to display all even numbers up to 100
Answers
Answered by
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:
- Line 1: Start of class.
- Line 2: Start of main() method.
- Line 3: Iterating a loop from i = 2 to 100 with condition - (i<=100), step value = 2
- Line 4: Display the value of i.
- Line 5: End of main().
- Line 6: End of class.
Refer to the attachment.
•••♪
Attachments:
Similar questions
History,
1 month ago
Hindi,
1 month ago
Math,
3 months ago
Biology,
9 months ago
India Languages,
9 months ago