category

Calculate power of a number using recursion in C language

Calculate power of a number using recursion in C language

In this tutorial, we will discuss the concept of  Calculate power of a given number using recursion in C language

In this post, we will learn how to  find the power of a given number using recursion in C  language

 

Program 1

#include <stdio.h>
#include <stdlib.h>
int find_Power(int num1,int num2);//function prototype
int main()
{
    int base, powerValue, result;

    printf("Enter base number: ");
    scanf("%d",&base);

    printf("Enter power number: ");
    scanf("%d",&powerValue);

    result=find_Power(base,powerValue);

    printf("%d^%d=%d",base,powerValue,result);
    getch();
    return 0;
}

int find_Power(int base, int powerValue)//
{
    if(powerValue !=0)
        return (base*find_Power(base,powerValue-1));
    else
        return 1;
}

When the above code is executed, it produces the following results

Enter base number: 4
Enter the power number: 5
4^5=1024

Pow() pre-defined function is used to calculate the power of a number raised to a decimal value

 

Suggested for you

C recursion

C input-output function

C function

C user defined function

Java program to find middle of three number using method
Calculate power of a number using recursion in C++
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago