Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write code for Factorial?

Answers were Sorted based on User's Feedback



write code for Factorial?..

Answer / rajender

private void btnCalculae_Click(object sender,
System.EventArgs e)
{
long number = Convert.ToInt64 (txtNumber.Text);
long factorial = 1;
lblFactorial.Text = factorial.ToString
("n20");

// calculate factorial

while ( number > 0 && number <= 20)
{
factorial *= number;
number++;
} // end while loop

txtNumber.Text = "";
txtNumber.Focus();
}

private void btnExit_Click(object sender,
System.EventArgs e)
{
this.Close();
}
}
}

Is This Answer Correct ?    10 Yes 1 No

write code for Factorial?..

Answer / 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

write code for Factorial?..

Answer / diana cheriyan

Using System;
Namespace FactNmspce
{
Class FactCls
{
Public Static Void Main(String[]args)
{
int i,n,fact=1;
Console.WriteLine("Enter Number");
n=int.Parse(Console.ReadLine());
for(i=1;i<=n;i++)
{
fact=fact*i;
}
Console.WriteLine("Factorial is {0}",fact);
}
}
}

Is This Answer Correct ?    12 Yes 5 No

write code for Factorial?..

Answer / shanker

int numberfactorial(int number)
{
if (number == 1) {
return number;
}
else {
return number * numberfactorial(number - 1);
}
}

Is This Answer Correct ?    1 Yes 1 No

write code for Factorial?..

Answer / dilip tekedil

public long Factorial(short num)
{
if (num == 1) return (long)1;
return num * Factorial(--num);
}

Is This Answer Correct ?    4 Yes 5 No

write code for Factorial?..

Answer / sathish

private void btnCalculae_Click(object sender,
System.EventArgs e)
{
string str =txt1.text;
int fact=1;
foreach char c in str
{
fact=convert.toint32(c)*fact;
}
txt2.text=fact;
}

Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More C Sharp Interview Questions

What is difference between managed and unmanaged code?

0 Answers   SwanSoft Technologies,


Is equal in c#?

0 Answers  


Define using statement in c#?

0 Answers  


What are the Types of JIT and what is econo-JIT

0 Answers   TCS,


what are pointer types in c#

0 Answers   Cognizant,


What is the usage of Enumeration in C# Programming and is it good to use or not ?

0 Answers   MCN Solutions,


What is a dll in c#?

0 Answers  


What does readonly mean in c#?

0 Answers  


What is the difference between final finally and finalize in c#?

0 Answers  


What are the 2 broad classifications of fields in c#?

0 Answers  


explain synchronous and asynchronous in C#

3 Answers   AxSys, Mastek, Synechron,


what is output parameter and parameter array?

1 Answers   TCS,


Categories