What is the function to find the nth power of x in C language?

angryTom
Release: 2020-02-26 10:51:31
Original
20290 people have browsed it

What is the function to find the nth power of x in C language?

#What is the function to find the nth power of x in C language

C languagepow() function is used Find the value of x raised to the power of y.

Header file: math.h

Syntax/Prototype:

double pow(double x,double y);
Copy after login

Parameter description:

x: Double precision number.

y: Double precision number.

Return value: the value of x raised to the power of y.

Recommended learning: c language video tutorial

Usage example:

Use the pow() function to find 6 times of 4 Square, the code is as follows:

#include <stdio.h>
#include <math.h>
int main() {
    double x = 4, y = 6;  //为变量赋初值
    double result = pow(x, y);  //求a的b次方
    printf("%lf\n", result);
    return 0;
}
Copy after login

Running results:

4096.000000
Copy after login

php Chinese website, a large number of Introduction to Programming tutorials, welcome to learn!         

The above is the detailed content of What is the function to find the nth power of x in C language?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template