Sunday, 5 February 2012

Write a C-Sharp .NET console application program for finding factorial of the given number.

Write a C-Sharp .NET console application program for finding factorial of the given number.


Program source code for finding factorial of the given number in C#.NET.

using System;
using System.Collections.Generic;
using System.Text;

namespace factorial
{
class Program
{

static void Main(string[] args)
{
int i, fact = 1, n;
String no;
Console.WriteLine("Enter a number:");
no = Console.ReadLine();
n = Convert.ToInt32(no);
for (i = 1; i <= n; i++)
{
fact = fact * i;
}
Console.WriteLine("factorial is:" + fact);
Console.ReadLine();
}
}
}

1 comment: