Click here to Skip to main content
15,921,226 members

assign fact=1 before using it.
 
Share this answer
 
You are multiplying fact with another value, but at that point in your code fact has not been initialised so it does not contain a valid number. You should add an initialisation statement before your loop, something like:
C#
fact = 1;
// your loop starts here


Also, in future please post you code and the error message into your question, rather than a link to a screen shot.
 
Share this answer
 
Public static int fact =0 before using
 
Share this answer
 
Give it an initial value...
At present, you declare it, and then immediately use it to multiply by itself. Since it doesn't have a specific start value, VS rightly complains.

C#
int fact = 1;


BTW: In future, don't be so lazy: copy and paste your code here (within a code block).
That way, if we need to compile or run it, we can - without having to type it in again ourselves. :doh:
Help us to help you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900