Q:

Write a program in c to calculate power using recursion

0

Write a program in c to calculate power using recursion

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include<stdio.h>
#include<conio.h>
long int power(int a,int b)
{
long int s=1;
int I;
if(b==0)
{
return 0;
}
for(i=1;i<=b;i++)
{
s=s*a;
}
return s;
}
void main()
{
long int p;
int c,d;
printf(“Enter any two number\n”);
scanf(“%d%d”,&c,&d);
p=power(c,d);
printf(“\n power is %d”,p);
getch();
}

Output:

Enter any two number :
2 4
power is 16

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program in c to find even or odd numbers... >>
<< Write a progran to calculate factorial of a numbe...