Skip to main content

Find Power in C

 




#include<stdio.h>

void main()
{
    int a,b;
    int c=1;
    printf("Enter the base: ");
    scanf("%d",&a);
    printf("Enter the exponent: ");
    scanf("%d",&b);
 
 for (int i = 1; i <=b ; i++)
 {
     c=c*(b,a);
 }
 printf("%d",c);
 
}


// Second Method

// #include <stdio.h>
// #include <math.h>

// int main()
// {
//     double base, power, result;

//     printf("Enter the base number: ");
//     scanf("%lf", &base);

//     printf("Enter the power raised: ");
//     scanf("%lf",&power);

//     result = pow(base,power);

//     printf("%.1lf^%.1lf = %.2lf", base, power, result);

//     return 0;
// }


Comments