I understand how to use pow()
correctly I'm just wondering why when I run this code ans
= inf.
I am having a hard time understanding this.
Does this have anything to do with chars only being able to take on the values -128 to +127 and the way pow()
is calculated?
Does this have anything to do with the space in " %c"
as in my first scanf
param?
Linux 4.9.0-7-amd64 debian 4.9.110-1 gcc version 6.3.020170516
#include <stdio.h>
#include <math.h>
int main ()
{
char base, exp;
float ans;
printf("Enter base number : ");
scanf(" %c", &base);
printf("Enter exp number : ");
scanf(" %c", &exp);
ans = pow(base,exp);
printf("%c raised to the %c power equals %f", base, exp, ans);
return 0;
}