How to get factorial in c#

May 02, 2013

How to get factorial in c#

Object


Write a program which calculates factorial of a number entered by the user until the user decides to exit.



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

namespace Calculator
{
    class Program
    {
      
        static void Main(string[] args)

char ch;

            int Value;
            int Fact = 1;
            do
            {
                Console.WriteLine(" Enter The Number Which Number You Want To Calculate The Factorial\n");
                Console.WriteLine(":___________________________________________________________________:");
                Console.Write("Number Is : ");
                Value = int.Parse(Console.ReadLine());
                for (int i = 1; i <= Value; i++)
                {
                    Fact = Fact * i;
                }
                    Console.WriteLine("Factorial is  : " + Fact);
          
           
              
                    Console.WriteLine("Do You Want TO Continue....(y/N)\n");

                    ch = char.Parse(Console.ReadLine());
           
            }
            while (ch == 'y');
       
           
        }
    }
}






 

You Might Also Like

0 comments

Popular Posts

Like us on Facebook

Flickr Images