Power function always giving a zero(0) as result no matter the input.
I am learning the power function, but it doesn't work.please help.
#include <stdio.h>
#include <math.h>
int main()
{
int A,B;
int C=pow(A,B);
printf("To find power please enter values of A and B \n");
printf( "Please enter value of A: \n");
scanf("%d",&A);
printf("Please enter value of B: \n");
scanf("%d",&B);
printf("The power of A and B is : %d",C);
return 0;
}
You're setting the value of C before you assign the A and C values.
Put
int C = pow(a, b);right before you runprintf("The power of A and B is : %d",C);Complete code
The tag powershell seems random, you should have the tag set to the language that you're using.