write code for Factorial?

Answer Posted / dharmendra nonia

using System;
class Factorial
{
public static void accept()
{
double a;
Console.WriteLine("Enter ur Number:");
a=Double.Parse(Console.ReadLine());
double res=fac(a);
Console.WriteLine(res);
}
public static double fac(double d)
{
if (d == 1)
return 1;
else
return d * fac(d - 1);
}
public static void Main()
{
accept();
Console.Read();
}
}

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is lazy keyword in c#?

526


What is poco c#?

480


can you allow a class to be inherited, but prevent the method from being over-ridden?

548


What is an arraylist in c#?

600


What is verbatim literal in c#?

486






What is static and use of it?

467


Can you create sealed abstract class in c#?

481


What is view state c#?

514


How does a while loop work?

472


What is the use of thread join in c#?

495


Is post back c#?

493


Is c# dictionary a hash table?

477


What is tpl in c#?

495


Can you use all access modifiers for all types?

537


What are jump statements in c#?

499