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.
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');
}
}
}
No comments:
Post a Comment