/*****************************
* Umang B Bhatt *
* bhatt.umang7@gmail.com *
*****************************/
/**
* program for finding power using recursion
*/
#include<stdio.h>
int fun(int a,int b)
{
if(b>1)
{
return a*fun(a,b-1);
}
else
{
return a;
}
}
void main()
{
int a =3 ;
int b = 2;
printf("\nEnter a: ");
scanf("%d",&a);
printf("Enter b: ");
scanf("%d",&b);
printf("%d^%d is: %d\n",a,b,fun(a,b));
}
No comments:
Post a Comment