cfuncs.c (1233B)
1 /* Exercise 5.49 */ 2 3 #include <stdio.h> 4 #include <math.h> 5 6 int main() 7 { 8 int i; 9 10 printf("\n\t\tPrint a lot of (math?) tables\n\n"); 11 12 /* sqrt(), exp() and log() */ 13 for(i = 1; i <= 10; i++) { 14 printf("sqrt(%.2f) == %.2f\t", (double)i, sqrt((double)i)); 15 printf("exp(%.2f) == %.2f\t", (double)i, exp((double)i)); 16 printf("log(%.2f) == %.2f\n", (double)i, log((double)i)); 17 } 18 19 printf("\n"); 20 21 /* fabs(), ceil() and floor() */ 22 for(i = 1; i <= 10; i++) { 23 printf("fabs(%.2f) == %.2f\t", (double)i, fabs((double)i)); 24 printf("ceil(%.2f) == %.2f\t", (double)i, ceil((double)i)); 25 printf("floor(%.2f) == %.2f\n", (double)i, floor((double)i)); 26 } 27 28 printf("\n"); 29 30 /* pow() and fmod() */ 31 for(i = 1; i <= 10; i++) { 32 printf("pow(%.1f, %d) == %.2f\t\t", (double)i, 3, pow( (double)i, 3) ); 33 printf("fmod(%.2f, 3) == %.2f\n", (double)i, fmod( (double)i, 3) ); 34 } 35 36 printf("\n"); 37 38 /* sin(), cos() and tan() */ 39 for(i = 1; i <= 10; i++) { 40 printf("sin(%.2f) == %.2f\t", (double)i, sin((double)i)); 41 printf("cos(%.2f) == %.2f\t", (double)i, cos((double)i)); 42 printf("tan(%.2f) == %.2f\n", (double)i, tan((double)i)); 43 } 44 45 return 0; 46 } /* E0F main */ 47