0
write a java program for even numbers between 100and 200?
5 odpowiedzi
+ 1
subash, your code increments by 1, so you'll get 101, 102, 103 etc... Author requested even numbers
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.
- 1
Just do a for loop. for(int i = 100; i <= 200; i +=2). println (i)
- 1
for (int i=100; i<=200; i+=2)
{
System.out.println(i);
}
- 5
while(int i =100&& i <= 200;i ++).println(i)