1 ANSWER THE FOLLOWING :-
Write a program to print even numbers from 2 to 200.
Answers
Answered by
0
Answer:
Here is a Java program that uses a for loop to print even numbers from 2 to 200:
public class EvenNumbers {
public static void main(String[] args) {
for (int i = 2; i <= 200; i += 2) {
System.out.print(i + " ");
}
}
}
This program uses a for loop to iterate from 2 to 200, incrementing the value of i by 2 in each iteration. Inside the loop, the current value of i is printed to the screen. Since the i is incremented by 2 in each iteration, it will only print even numbers.
Similar questions
Social Sciences,
1 month ago
English,
1 month ago
Social Sciences,
1 month ago
English,
3 months ago
Hindi,
3 months ago
Business Studies,
10 months ago
Hindi,
10 months ago
Hindi,
10 months ago