OK then, do you know how a for loop works? I'll walk it through with you:
1 2 3 4
|
for (initialization ; condition ; update)
{
looped code
}
|
For loops are traditionally used to run something for a determinate number of executions. Therefore, the loop's syntax is designed to accommodate a counter.
The initialization is ran only at the first execution of the for loop, before any looped code is ran. It is usually used to set the counter for the loop to a desired starting value - in many cases, 0 or 1.
The condition is the factor that determines if the loop will keep running. It is checked at the beginning of each iteration of the loop, including the first (immediately after the initialization, I believe). If the condition is ever false, the loop will stop before executing its code. The condition is usually bound to the value of the counter in some way.
The update is used to modify the counter after each execution of the loop. After the code in the loop is executed, the update's code is then performed. This particular statement is usually what makes the counter's value change over executions of the loop, eventually causing the loop's condition to become false. In the vast majority of cases, at least to my experience, the update code consists of incrementing the counter by 1.
Therefore, your counter would be some arbitrary new variable, set at 0 in the initialization. As long as the counter is LESS THAN the exponent value inputted by the user (the condition, catching on?), you will, in the code of the loop, multiply the result by the base. (Outside the loop, you'd set the result to 1.) Finally, you would increase your counter variable by 1. You will execute this loop "exponent" times (as many times as the value of the exponent).
See?
(By the way, if this charade is tiring you, I'm NEVER EVER going to post you an immediate answer. I'll tutorial you this far, maybe even farther if you are civil and clear, but never ever will I give you the answer. That's just how I roll.
http://xkcd.com/524/)