I'm new to C++, and I'm trying to solve a problem to compute an exponent of an integer to a float. The following is the psuedo code:
Declare x as a float
Declare y as an integer
Declare i as an integer
Declare result as a float
Input x //any float
Input y //positive integer
set result = 1 //intial valuue
For i = 1 to y
result = result *x
end for
output result
I have no problem with declaring the variables or reading in the variables. I have problems with my calculations using the "for loop". This is what I have so far:
For (i = 1; y>=0; i++);
{
result = result *x;
End for
}
The program is suppose to allow the user to input the variables (x,y) to solve x^y. I know a number multiplied by itself would give you the exponent, but I'm missing something to allow me to do that.
Thanks in advance for your help.
dkm30