Calculate the Power of a Number Using pow() Function
1 |
#include <stdio.h>#include <math.h>int main(){double base, exponent, result;printf("Enter a base number: ");scanf("%lf", &base);printf("Enter an exponent: ");scanf("%lf", &exponent);// calculates the powerresult = pow(base, exponent);printf("%.1lf^%.1lf = %.2lf", base, exponent, result);return 0;}//OutputEnter a base number: 2.3Enter an exponent: 4.52.3^4.5 = 42.44</math.h></stdio.h> |