Sunday, 22 September 2013

Console Application : Simple Factorial Program.

Steps To Create Factorial's Program in Console Application.

1. Create New Console Application Program
2. Name It As "Factorial".
3. Open Program.cs.
4. Replace Your Program.cs Code With Below Code.

Program.cs


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

namespace Factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "Factorial";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Enter The Number = ");
            int n = Int32.Parse(Console.ReadLine());
            int fact = 1;
            int i;
            for (i = n; i > 0; i--)
            {
                fact = fact * i;

            }
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Factorial is = " + fact);
            Console.ReadKey();

        }
    }
}


5. Compile And Run Your Console Application Project.
6. Kindly Enter The Particular Value To Get It's Factorial.

My Output.



All The Best :)

1 comment: