Computer Science, asked by Anonymous, 8 months ago

Write a java program to print even and odd numbers till 50.

Answers

Answered by sahanasusamagmailcom
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 rbmythili6666
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