26 December 2011

C Program to Find "a" to the power "b"

Leave a Comment


Program to Find "a" to the power "b"






#include<stdio.h>

//declaration of function
int pro(int , int);

void main()
{
int a ,b,c ;
printf("enter the numbers :");
scanf("%d%d" , &a , &b);
c = pro(a,b);
printf("%d to the power %d is %d",a,b,c);
}

//definition of function which is finding a to the power b
int pro(int x,int y)
{
int c=1,d=1;
if(y==0)
printf("%d" ,1);
if(x==0)
printf("%d", 0);
if((x!=0&&y!=0))
{
while(c<=y)
{
d*=x;
++c;
}
}
return d;
}

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

0 comments:

Post a Comment