Read number(N)keyed in by user
Set factorial to 1
While N is not equal to 0
Set factorial=factorial*N
Set N= N-1
End While
Display factorial

Recommended Answers

All 11 Replies

What have you done so far? in codeing that is

what i have done is this:

String factorial;//declare variable factorial

factorial=1;
While N != 0
{
     factorial*N=factorial;
     N--;
}

DisplayLabel.Text=factorial.ToString

Where is the user input?
Why is factorial a string?
Why are you assigning an integer to a string?
That while statement won't compile.
The factorial assigment statement is incorrect.
The final statement will not compile.

Then may i know what is the right way to do please?

Where is the user input?

Where is N defined, N is the input
Get the input from the user.

Why is factorial a string?

Make factorial an integer

Why are you assigning an integer to a string?

I think he was saying why are you assigning it as string where it should have been an integer

That while statement won't compile.

You need to add apprentices on your condition.

The factorial assigment statement is incorrect.

factorial*N=factorial; where did you learn programming man?
its factorial = ;

The final statement will not compile.

You are missing a ;

did you try to compile this?

I can see you are very new to programming. Which is OK, please tell me if you need further clarification.

thanks fpr helping and ya im very new to programming.just started 2 weeks ago.i need great help...im like cracking my head on how to programming the right way for certain applications right now.

ok please mark as solved if solved.

Visual studio still does'nt run this program right.what is wrong with my code.what can i do to run the program well?

this is what i added in the coding:

    private void button1_Click(object sender, EventArgs e)
    {
   int factorial;
  factorial=1;

  While (N != 0);
  {
  factorial= factorial*N;

  N--;
  }
  factorialDisplay.Text = factorial.ToString;

Where is your input?

you haven't initialized N.

factorialDisplay.Text = factorial.ToString();

What is the Error. If you read it you should be able to tell.

Where is your input?

you haven't initialized N.

factorialDisplay.Text = factorial.ToString();

What is the Error. If you read it you should be able to tell.

is it supposed to be
factorialDisplayLabel.Text=Convert.ToInt();

try factorialDisplay.Text = factorial+"";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.