Ask Question - Get Answer

1 Ans Write a C program to implement x power n using recursion

Asked by AL MaMun (4 Golds) Friday, 31 Jul 2020, 04:47 PM at (Education Tutorials)

Please log in to answer, like and save
0
Save 0

<<< Previous
Log in to Answer Next >>>

Answer(s):

Implementing x power n using recursion :


#include<stdio.h>

#include<math.h>

int power(int x, int n)

{

    if(n)

    {

        return x * power(x, n-1);

    }

    return 1;

}

int main()

{

    int x, n, result;

    scanf("%d%d", &x, &n);

    result=power(x, n);

    printf("%d", result);

    return 0;

}

 

Answered by AL MaMun (4 Golds) Friday, 31 Jul 2020, 04:48 PM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

1 Ans Write a C program to print Fibonacci number series

2 Ans Write a C program to implement Selection sort data structure and algorithm

1 Ans Write a C program to Find Armstrong Number series upto a Number

1 Ans Write a C program to find the highest and lowest number in a series

1 Ans Bank Exam all important Writing Materials

1 Ans Write a C program to find nth Fibonacci number

2 Ans Write a C program for Binary Search algorithm

1 Ans Write a C program to reverse a number

1 Ans Write a C program to implement Insertion sort data structure and algorithm

3 Ans Three ways to find Greatest Common Divisor (GCD) and Least Common Multiple (LCM) in a C program