WAP to find power if any number which is given by user without MATH.H header file


#include<conio.h>
#include<stdio.h>
int power(int x,int y);
void main( )
{
 int x, y;
 int pow;

 clrscr();
 printf("\nEnter two numbers: -");
 scanf("%d %d",&x,&y);

 pow=power(x,y);
 printf("\n%d to the power %d=%d",x,y,pow);

 getch();
 }

 int power(int x,int y)
 {
  int i;

  int p=1;
  for(i=1;i<=y;i++)

   p=p*x;
   return (p);

}

No comments:

Post a Comment