Want to create a program that asks the user to input 2 numbers and output the first number to the power of the second one. Here is my code
void func4()
{
double f;
double g;
double result;
printf("Enter first number:\n");
scanf_s("%d", &f);
printf("Enter second number number:\n");
scanf_s("%d", &g);
result = pow(f, g);
printf("%f", result);
}
But when I put the numbers the output is always zero.
P.S. Libraries stdio.h and math.h are added in the header
CodePudding user response:
%d
format specifier is for reading int
. You have to use proper specifier. You can use %lf
for reading double
.