Friday, 23 September 2016

Power by Recursion

/* Power by Recursion */

#include<stdio.h>
int pow(int,int);

int main()
{
int i,j;
printf("Type two values : \n");
scanf("%d %d",&i,&j);

printf("i pow j = %d",pow(i,j));
return 0;
}

int pow(int i,int j)
{
if(j==1)
return i;
return (i*pow(i,j-1));
}

No comments:

Post a Comment

Featured post

Will AI Replace Programmers? The Truth Behind the Hype in 2025

Exploring the Future of Coding: Will AI Take Over Software Development or Enhance It?  Will AI Replace Programmers? The Truth Behind the Hyp...