cfant said:
You haven't included math library. Compile and link your program like this:
gcc -o math math.c -lm
and here is the output:
2.302585 3.321928 5.477226
o thats good,works fine thanks for reply.but still it is giving me some warning like this
ejaz@msiddique:~/cproj$ gcc -o math math.c -lm
math.c: In function ‘main’:
math.c:6: warning: incompatible implicit declaration of built-in function ‘log2’ejaz@msiddique:~/cproj$ ./math
2.302585 3.321928 5.477226ejaz@msiddique:~/cproj$
ok also i want some explanation about this.
does math library is not in standered c library ? for which of header files we need to link them? does -lm command is sufficient to link any library?
thanx for your nice guide
Added after 1 hours 6 minutes:
also there is problem with double data types.look at the program
// programe to calculate income tax
#include<stdio.h>
int main(void){
const double TAX_RATE = 0.025;
double grossIncome ,totalTax;
printf("Enter the value of income in rupeese");
scanf("%f",&grossIncome);
totalTax = grossIncome * TAX_RATE;
printf("total tax is %f \n",totalTax);
return 0;
}
here is the output
ejaz@msiddique:~/cproj$ gcc -o tax tax.c
ejaz@msiddique:~/cproj$ ./tax
Enter the value of income in rupeese100.0
total tax is -0.000000
ejaz@msiddique:~/cproj$