Java Program to Print Odd Numbers from 1 to N - The Coding Shala
In this post, we will learn How to Display Odd Numbers from 1 to N using Java Program.
Java Program to Print Odd Numbers from 1 to N
Write a Java Program to print odd numbers from 1 to given n.
We can use a for loop from 1 to given n and will check if the current number is divisible by 2 then it is an even number else it is an odd number. We will print all the odd numbers.
We can also start the for loop from 1 and increase it by 2 and print all the numbers till n.
- Java Program to Print Even Numbers from 1 to N
- Java Program to Check if a Number is a Palindrome
- Java Program to Reverse a Number
- Java Program to Check if a String is a Palindrome
- Java Program to Reverse a String