Basically, I am trying to find the logarithm of a number using the log(x) function in the math.h library of C. But, for any and every value that I enter for the variable x, I end up with the same answer: -722.259365. Where is the problem with my code below?
I am kind of new to C, so please don't mind if this is too silly a mistake.
#include<stdlib.h>
#include<math.h>
void PrintLogarithm(double x){
if(x<=0){
printf("Positive numbers only please.\n");
return;
}
double Result = log(x);
printf("%f\n", Result);
}
int main(){
double x;
scanf("%f", &x);
PrintLogarithm(x);
return 0;
}
I am kind of new to C, so please don't mind if this is too silly a mistake.