I been struggling with this piece of code and I can't really figure out what is wrong with it. The code simply takes an input integer k from the user, passes it to the powerOfTen function along with a pointer of type double, and calculates the result. But, when I store the result inside the *my_dbl and try printing that value through *my_double, I get nothing as a result.
#include <stdio.h>
void powerOfTen(int k, double *my_dbl);
int main()
{
int k;
double *my_double;
scanf("%d", &k);
power_of_ten(k, my_double);
printf("%.15lf\n", *my_double);
}
void power_of_ten(int k, double *my_dbl)
{
double result = 1.0;
if(k >= 0){
for(int i = 0; i < k; i++) result = result*10.0;
} else{
for(int i = 0; i < (0-k); i++) result = result/10.0;
}
// printf("%f\n", result);
*my_dbl = result;
}