Header Ads Widget

Program to calculate power of a number in c language.

program:-

#include<stdio.h>
#include<conio.h>

//function definition power

int pow(int a,int n)
{
if(n==0)
return 1;
else
return a*pow(a,n-1);
}
void main()
{
int a,n,p;
printf("Enter number and it's power");
scanf("%d%d",&a,&n);
p=pow(a,n); //function calling
printf("result=%d",p);
getch();
}



     

Post a Comment

12 Comments