计算给定数字的幂的C程序
从用户那里获取两个整数作为底数和指数,并按照下面的说明计算幂。
示例
考虑以下内容以编写一个C程序。
- 假设底数为3
- 指数为4
- 幂=3*3*3*3
算法
按照下面给出的算法进行操作:
Step 1: Declare int and long variables. Step 2: Enter base value through console. Step 3: Enter exponent value through console. Step 4: While loop. Exponent !=0 i. Value *=base ii. –exponent Step 5: Print the result.登录后复制