pow function in C programming Language

In this tutorial, we will discuss pow function in C programming Language

Description

Pow()  in C is used to find the power of the given number

The pow() function in C programming language (C library function) returns x raised to the power of y

pow(): In the C Programming Language, The pow() Arithmetic function calculate x raised to the power of y

 

Declaration

The declaration for the pow()  in the C Programming language is

double pow(double x,double y );

Parameter or Argument

parameter of pow() function is:

x,y are the arguments of this function

 

Return

The pow() function returns x raised to the power of y

Required header

In this Language, The required header for the pow function is

#include <math.h>

Example

The following example shows the usage of pow()

pow function in C

program 1
#include <stdio.h>
#include <math.h>
int main()
{

    printf("The Power value of pow(2,3) is %f\n",pow(2,3));
    printf("The Power value of pow(3,4) is %f\n",pow(3,4));
    getch();
    return 0;
}

 

When the above program is compiled, it will produce the following result

The power value of pow(2,3) is 8.000000

The power value of pow(3,4) is 81.000000

 

Example 2

#include <stdio.h>
#include <math.h>
int main()
{
    //define temporary variable
    double val1,val2;
    double result;
    printf("Enter the number one :");
    //get first input from user
    scanf("%lf",&val1);
    printf("Enter the number two :");
    //get second input from user
    scanf("%lf",&val2);
    //calculate power
    result=pow(val1,val2);
    //Display power value
    printf("power value is: %lf\n",result);
getch();
    return 0;
}

When above program is compiled, it will produce the following result

Enter te number one :5
Enter te number two :6
Power value is :15625.000000

 

Suggested for you

trunc() function in C langue

exp() function in C language

sqrt() function in C language       

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

round function in C language

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

 

 

trunc function in C programming language
sqrt function in C programming language
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…

6 months ago

PHP Full Pyramid pattern program

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

6 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…

6 months ago

Python Full Pyramid star pattern program

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

9 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…

1 year 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,…

1 year ago