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 CASPOL?

782


How do I unload an application domain?

687


What is native image generator (ngen.exe)?

875


Can we make a class private in c#?

683


What is the relationship between a process, application domain, and application?

705


Can datetime be null c#?

627


Hi Friends, I am going through Siemens Interview Procedure from last 1+1/2 months. I went through 1 written + 2 Technical + 1 Managerial Round process after which I got call from HR informing that "you are selected and we would like to meet you for HR round". HR round was very nominal compared to MR. HR Round last for hardly 5 mins. They told me that you will get the final result on Friday. Still I have not received any feedback from them. Please help!!!

16853


Is vs as c#?

679


List the differences between method overriding and method overloading?

652


What is the process of delegation?

682


What does protected internal access modifier mean?

734


Can you inherit from a sealed class?

654


What is the benefit of interface in c#?

668


Define a partial class?

649


Can an abstract class have a constructor c#?

655