Saturday, January 30, 2010

CHAP 3[B]c Finding power of a value

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.

void main()
{
float a,p,t;
printf("\nInput two number, first is digit second is power");
scanf("%f%f",&a,&p);
t=1;
while(p>0)
{

t=t*a;
p--;
}

printf("\nThe answer is %f",t);
}

1 comment: