Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Tuesday, 5 July 2011

Write a program that print all odd numbers from 0 to a user specific number using do while loop

import java.util.*;
class odd
public static void main (String arg[])
Scanner in = new Scanner (;
int a;
System.out.print ("\n\t Enter the ending number = ");
if (a%2!=0)
System.out.print ("\n\t "+a);
}while (a>0);


        In this program if we divide a by 2 and it do not returns 0, then it will be printed on
screen otherwise not.

No comments:

Post a Comment