Home >Backend Development >C#.Net Tutorial >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.
#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.
#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.
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.
#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.
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!