Write a java program to print even and odd numbers till 50.
Answers
Answered by
2
class JavaExample {
public static void main(String args[]) {
int n = 100;
System.out.print("Even Numbers from 1 to "+n+" are: ");
for (int i = 1; i <= n; i++) {
//if number%2 == 0 it means its an even number
if (i % 2 == 0) {
System.out.print(i + " ");
}
}
}
}
Answered by
0
Answer:
Java Program to print Odd and Even Numbers from an Array
public class OddEvenInArrayExample{
public static void main(String args[]){
int a[]={1,2,5,6,3,2};
System.out.println("Odd Numbers:");
for(int i=0;i<a.length;i++){
if(a[i]%2!=0){
System.out.println(a[i]);
} was
Explanation:
follow me and mark as brainlist answer
please follow me because to become 50 followers please please
Similar questions