
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Pow Function in C
The function pow() is used to calculate the power raised to the base value. It takes two arguments. It returns the power raised to the base value. It is declared in “math.h” header file.
Here is the syntax of pow() in C language,
double pow(double val1, double val2);
Here,
val1 − The base value whose power is to be calculated.
val2 − The power value.
Here is an example of pow() in C language,
Example
#include<stdio.h> #include<math.h> int main() { double x = 5.5; double y = 4.0; double p; p = pow(x, y); printf("The value : %lf", p); return 0; }
Output
The value : 915.062500
On some online compilers, the following error may occur.
undefined reference to `pow' error: ld returned 1 exit status
The above error occurs because we have added “math.h” header file, but haven’t linked the program to the following math library.
libm.a
Link the program with the above library, so that the call to function pow() is resolved.
Advertisements