Search This Blog

Saturday, 7 September 2013

Factorial using C#

Finding Factorial

using System;

class no
{
    int a,fact;
   
    public void input()
    {
        Console.WriteLine("Enter the number for finding Factorial:");
        a=Convert.ToInt32(Console.ReadLine());
    }
   
    public void output()
    {
        int f=1,i;
        for(i=1;i<=a;i++)
        {
            f=f*i;
        }
        Console.WriteLine("Factorial of the entered number is:{0}",f);
    }
}

class Factorial
{
    public static void Main(String[] args)
    {
        no obj=new no();
        obj.input();
        obj.output();
       
    }
}

output:







No comments:

Popular Posts