Question: Consider the following program. What is the correct assignment to temp at ? ? ? ? which will ensure that the correct result ( i

Consider the following program. What is the correct assignment to temp at ???? which will ensure that the correct result (i.e. x^exp) is returned?
int power (int exp, int x){
if (exp==0) return 1;
else {
int temp=????
if (exp%2==0) return temp;
else return temp*x;
}
}
Question 2Select one:
a.
power (exp/2, x*x)
b.
power ((exp-1)/2, x*x)
c.
power ((exp-1)/2, x)* power ((exp-1)/2, x)
d.
power (exp/2, x)* x
e.
None of the others.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!