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.

Thursday, 7 July 2011

Write a program to print factorial of any number using do while loop

import java.util.*;
class factorial
public static void main (String arg[])
Scanner in = new Scanner (;

int a,b=1;
System.out.print ("\n\t Enter the number = ");

}while (a>0);

System.out.println ("\n\t Factorial = "+b);


        In this program first of all body of the loop will be executed then its condition will be checked if it is true then body of the loop will be executed again otherwise not. This will continue until a=0. When a=0 the loop will be broken and the next statement to it will be executed.


  1. I wish to commence with $2 via alertpay. Help me.
    Here is my website

  2. Its such as you read my mind! You appear to understand so much about this,
    such as you wrote the e-book in it or something.
    I think that you just could do with a few % to force the message home a bit, however instead of that, this is great blog. A fantastic read. I'll certainly be back.
    Also visit my blog :: optin emails purchases

  3. pls show me the output of this program

  4. Suppose a=5
    Represents b=b*a
    We already have b=1
    So b=1*5
    later it checks the condition (a>0)
    so condition is true
    So then
    it represents 4
    now the ouput of b=5 will be mutiplued with 4 it will become 20 now b=20
    Then it checks condition (a=4<0) true aagain a-- it will become 3 again it is munyiplied with 2 and then 1