write a java program for even numbers between 100and 200? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

write a java program for even numbers between 100and 200?

21st Jul 2016, 7:31 AM
honey
honey - avatar
5 Answers
+ 1
subash, your code increments by 1, so you'll get 101, 102, 103 etc... Author requested even numbers
21st Jul 2016, 8:23 AM
James
James - avatar
0
int start = 100; int end = 200; for(int i = start; i <=end; i++){ if( i % 2 == 0 ){ System.out.println("even num "+i); } } There's many ways to do it by the way but this is the simplest i think and for more about that research on stack overflow.
21st Jul 2016, 9:45 AM
Ousmane Diaw
- 1
Just do a for loop. for(int i = 100; i <= 200; i +=2). println (i)
21st Jul 2016, 7:55 AM
James
James - avatar
- 1
for (int i=100; i<=200; i+=2) { System.out.println(i); }
21st Jul 2016, 12:42 PM
Ian Dandridge
Ian Dandridge - avatar
- 5
while(int i =100&& i <= 200;i ++).println(i)
21st Jul 2016, 8:20 AM
subash 143
subash 143 - avatar