Hello all,

I'm working with exponentiation and I have an assignment to write a code for loop initialization and loop body but unfortunately, I don't even know what that means.

I was given the following information:

Input x // can be any float
Input y // has to be a positive integer

Set result = 1 // initial value

For i = 1 to y
result = result * x

Can anyone PLEASE translate what that means and show me an example of a loop initialization and loop body code? Please advise if you need more info. I apologize in advance for being slow.

Input = cin
x is a float
y is a int
r is a int

for i to y means :

for(int i = 1; i < y; i++)
{
   //code goes here
}

The "code goes here" part is result = result * i;

Input = cin
x is a float
y is a int
r is a int

for i to y means :

for(int i = 1; i < y; i++)
{
   //code goes here
}

The "code goes here" part is result = result * i;

Thanks for the help. I'll try that. I'm still very new to programming.

This question has already been answered. Start a new discussion instead.