Computer Applications
Write a program in Java using for loop to print all the odd and even number upto 30 terms.
Java
Java Iterative Stmts
60 Likes
Answer
public class KboatEvenOdd
{
public static void main(String args[]) {
System.out.println("Odd numbers: ");
for (int i = 1; i <= 60; i += 2) {
System.out.print(i + " ");
}
System.out.println();
System.out.println("Even numbers: ");
for (int i = 2; i <= 60; i += 2) {
System.out.print(i + " ");
}
}
}
Output
Answered By
27 Likes
Related Questions
Write a program to print all the factors of 20.
Generate the following series upto 10 terms:
1, 8, 27, 64, 125 ……..
Write a program using while loop to generate the first 10 natural numbers and their sum.
Program to check whether the product of two numbers is a buzz number or not.
[A number that ends with 7 or is divisible by 7, is called a buzz number]