Pages

Wednesday, May 22, 2013

Write a program for finding factorial of the given number in c#

public partial class factorial_a_given_no : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Console.Write("Enter a Number: ");
        int num;
        num = Convert.ToInt32(Console.ReadLine());
        int fact;
        fact = 1;
        for (int i = 1; i <= num; i++)
        {
            fact = fact * i;
        }
        Console.WriteLine("Factorial is :" + fact);
    }
}

No comments:

Post a Comment