Write a program to Calculate the Power of a Number.
C Program
#include <stdio.h>int main(){int base, power;int i;printf("Enter the base value : ");scanf("%d", &base);printf("Enter the power value : ");scanf("%d", &power);int powerAnwer = 1;for (i = 1; i <= power; i++){powerAnwer = powerAnwer * base;}printf("Power is %d", powerAnwer);return 0;}
Input:
Enter the base value : 4
Enter the power value : 2
Output:
Power is 16
No comments:
Post a Comment