write code for Factorial?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is xor operation?

693


Can we inherit partial class in c#?

658


For read-only operation which property you have to designated?

790


How do you pronounce c#?

665


Tell us something about static linking and dynamic linking?

702


What does void do in c#?

708


What does == mean in c sharp?

683


Is datetime value type c#?

624


How to move to a state-related codebase?

1148


What is thread life cycle in c#?

664


What is inline function in c#?

691


What is using keyword?

675


1. Describe page life cycle?

1792


How do you determine whether a string represents a numeric value?

698


How do I create a new form in c#?

688