Answers for "write a program to print even and odd numbers in java"

1

Java code to print odd number

class JavaExample {
   public static void main(String args[]) {
	int n = 100;
	System.out.print("Odd Numbers from 1 to "+n+" are: ");
	for (int i = 1; i <= n; i++) {
	   if (i % 2 != 0) {
		System.out.print(i + " ");
	   }
	}
   }
}
Posted by: Guest on August-19-2021

Code answers related to "write a program to print even and odd numbers in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language