Have you tried multiplying p n times? Do you know about loops yet?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
It's called using a flow chart. Draw one for the code (presuming it works) and all should become clear.
Trace each step with your finger and write the results on paper.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>ok i got the loop i just dont understand it
Translation: I ganked this code, but I need to know how it works to get credit for my homework. ;)
>can some one explain it quick
What don't you understand? It's a simple loop that counts p times and continually updates the result by multiplying n into it.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
You might, for the sake of clarity, want to chage
result *= n; to result = result * n;
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>You might, for the sake of clarity, want to chage
>result *= n; to result = result * n;
Why? It's not like this is a huge stumbling point for beginners.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401