How to write x raised to the yth power in c program

藏色散人
Release: 2021-06-17 11:50:50
Original
9841 people have browsed it

The method of writing x to the power of y in c program: first create a new project file in c language; then define two parameters n and k, which represent the input number and the required power number respectively; and finally use recursion The calculation to the nth power can be completed by multiplying n by the decreasing k.

How to write x raised to the yth power in c program

The operating environment of this article: windows7 system, Dell G3 computer/C11.

How to write x to the power of y in c program?

Create a new C language project file and introduce the header file. Here, first define a poetry function to process the calculation of x raised to the yth power. Define two parameters n and k, which represent the input number and the required times respectively. Power number:

How to write x raised to the yth power in c program

In the Poewer function, consider the situation where the k-th power is 1 and 0, and then use a recursive method to multiply n by the decreasing k to instantly complete n Calculation of powers. Then define the input data in the main function, use the scanf function to accept the value, call the power function to calculate, and finally output the result:

How to write x raised to the yth power in c program

Run the program, first enter the number 5, Press Enter, then enter the number 6 and press Enter. Finally, the program prints the result of 5 raised to the power of 6. The above is a demonstration of using C language to find the Y power of X:

How to write x raised to the yth power in c program

Recommended: "c Language Tutorial"

The above is the detailed content of How to write x raised to the yth power in c program. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!