Home>Article>Backend Development> How to input nth power in C language?

How to input nth power in C language?

烟雨青岚
烟雨青岚 Original
2020-06-23 13:57:16 39514browse

How to input nth power in C language?

How to input nth power in C language?

Method:

1. To find the nth power of a certain number in C language, you need to use the pow function, and to call this function, you need First add the math.h header file, the code is as shown below.

How to input nth power in C language?

#2. Then define two floating-point variables and assign values, as the base and exponent respectively, as shown in the figure below, and then define a variable to store the calculation result.

How to input nth power in C language?

#3. Use the Pow function to directly find the nth power of a number. The function has two parameters, the first parameter is the base, and the second parameter is the exponent, respectively. Put the represented variables into the function, as shown in the figure below.

How to input nth power in C language?

4. Finally, use the Printf function to print the operation result to the screen and check whether the result is normal, as shown in the figure below.

How to input nth power in C language?

#5. Debugging and running, you will get the nth power of the specified number in C language. The result is as shown in the figure below.

How to input nth power in C language?

Recommended tutorial: "C Language"

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

Statement:
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