1. Another urgent help, plz reply fast

Ok, here is another question I got confused in the exam paper. As far as I know, to calculate some power of a number is like this

pow (x,y)

But then, the question mentions about the while repetition. How to end it? Or what is the while (condition) in this case? Someone help me here again plz. And reply fast cuz I got programming exam to tomorrow and i need to know how this question is done. (The question is below here)

------------------------------------------------------------------------------------

(Exam Question): Write a C program that calculates x to the y power. The program should have a while repetition control structure.(5 marks)

2. The pow() function is raises x to the y, you can also raise x to the y by multiplying x by x, y times. Use that.

3. aha, ok, how bout while condition?

ok, the pow part i understood, but what about the while condition. That is the part in the exam question that confuses me this most. I mean, i dont know what the while (condition) is. how should it be written?

4. you can also creat a for loop .. here is how i did it...

case '^':

{

for(i=0; i<y; i++)

result *=x;

break;

5. so if y = 5 you would do this:-

x * x * x * x * x

With a while loop you should look at when you want to stop executing and then make sure the condition only becomes false at that point,

e.g. here you want to stop executing after you have multiplied x by itself 5 times:

i=0;
while(i < 5){
x = x*x;
i++
}
return x;

where i<5 means 'while i < 5 do this'

i.e. i=5 means it will no longer loop

So to get this to work with y you could just substitute 5 with y.