Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java Program to print Odd Numbers!

Hi Readers, In this post, we are going to write a core Java Program to Print Odd Numbers within a given limit.

First of all, you should know how to find an Odd Number and it is pretty simple, divide any number by 2 if the remainder is not zero then it’s an Odd number.

So let’s see the complete Java Program here:

 * @author agur
import java.util.Scanner;

public class PrintOdd {
    public static void main(String[] args){
        int limit, i;
        //create a scanner object to get the input
        Scanner in = new Scanner(;
        //get the limit from user
        System.out.print("Enter the limit:");
        limit = in.nextInt();
        //print the odd numbers
        System.out.println("Odd numbers:");
        //loop till the limit
        for(i=1; i

Read the inline comments to understand the logic.

The output of the above program:

Enter the limit:10
Odd numbers:
BUILD SUCCESSFUL (total time: 2 seconds)


The post Java Program to print Odd Numbers! appeared first on TutorialsMade.

This post first appeared on TutorialsMade - Ultimate Tutorial, please read the originial post: here

Share the post

Java Program to print Odd Numbers!


Subscribe to Tutorialsmade - Ultimate Tutorial

Get updates delivered right to your inbox!

Thank you for your subscription