C Program to calculate the power of a number without using Math.h library

#include<stdio.h>
int main()
{
    int base,power;
    printf("Enter the base number\n");
    scanf("%d",&base);
    printf("Enter the power\n");
    scanf("%d",&power);
    int res=1,i;
    for(i=1;i<=power;i++)
    {
        res=res*base;
    }
    printf("The result is : %d",res);
    return 0;
}

Output:
C Program to calculate the power of a number



Comments