Pages

Wednesday, April 3, 2013

Factorial Program in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, n, fact = 1;
            Console.WriteLine("Enter a Number");
            n = Convert.ToInt16(Console.ReadLine());
            for (i = 1; i <= n; i++)
            {
                fact = fact * i;
            }
            Console.WriteLine("Factorial of {0} is {1}",n,fact);
            Console.ReadKey();
        }
    }

}

3 comments:

  1. Thanks for sharing use interview questions on .Net technology. While preparing for my job interview, your article helped me a lot to sharpen my skills and do well in my interview. one of trainer from leading dot net training institutes in Chennai suggests me about your site.

    ReplyDelete