Program to caluclate power of number
#include<stdio.h>
#include<conio.h>
void main()
{
float x,power=1,i;
int y;
clrscr();
printf("enter the base and power ");
scanf("%f%d",&x,&y);
for(i=1;i<=y;i++)
power*=x;
printf("\n%f raised to %d is %f",x,y,power);
getch();
}
/*
output:-
----------
enter the base and power 5 6
5.000000 raised to 6 is 15625.000000
*/
#include<conio.h>
void main()
{
float x,power=1,i;
int y;
clrscr();
printf("enter the base and power ");
scanf("%f%d",&x,&y);
for(i=1;i<=y;i++)
power*=x;
printf("\n%f raised to %d is %f",x,y,power);
getch();
}
/*
output:-
----------
enter the base and power 5 6
5.000000 raised to 6 is 15625.000000
*/
The power of a number(baseexponent)is the base multiplied to itself exponent times.
ReplyDeleteFor Example power of a number
ab = a x a x a .....x a(b times)
24 = 2x2x2x2 = 16