checkmf.c (1745B)
1 /* Esercizio 5.3 */ 2 3 #include <stdio.h> 4 #include <math.h> 5 6 int main() 7 { 8 printf("Expr\t\tBook\t\tCheck\n"); 9 10 /* sqrt(3) */ 11 printf("sqrt(900.0)\t30.0\t\t%.1f\n", sqrt(900.0)); 12 printf("sqrt(9.0)\t3.0\t\t%.1f\n", sqrt(9.0)); 13 printf("\n"); 14 15 /* exp(3) */ 16 printf("exp(1.0)\t2.178282\t%f\n", exp(1.0)); 17 printf("exp(2.0)\t7.389056\t%f\n", exp(2.0)); 18 printf("\n"); 19 20 /* log(3) */ 21 printf("log(2.718282)\t1.0\t\t%.1f\n", log(2.718282)); 22 printf("log(7.389056)\t2.0\t\t%.1f\n", log(7.389056)); 23 printf("\n"); 24 25 /* log10(3) */ 26 printf("log10(1.0)\t0.0\t\t%.1f\n", log10(1.0)); 27 printf("log10(10.0)\t1.0\t\t%.1f\n", log10(10.0)); 28 printf("log10(100.0)\t2.0\t\t%.1f\n", log10(100.0)); 29 printf("\n"); 30 31 /* fabs(3) */ 32 printf("fabs(5.0)\t5.0\t\t%.1f\n", fabs(5.0)); 33 printf("fabs(0.0)\t0.0\t\t%.1f\n", fabs(0.0)); 34 printf("fabs(-5.0)\t-5.0\t\t%.1f\t*\n", fabs(-5.0)); /* diff */ 35 printf("\n"); 36 37 /* ceil(3) */ 38 printf("ceil(9.2)\t10.0\t\t%.1f\n", ceil(9.2)); 39 printf("ceil(-9.9)\t-9.0\t\t%.1f\n", ceil(-9.9)); 40 printf("\n"); 41 42 /* floor(3) */ 43 printf("floor(9.2)\t9.0\t\t%.1f\n", floor(9.2)); 44 printf("floor(-9.8)\t-10.0\t\t%.1f\n", floor(-9.8)); 45 printf("\n"); 46 47 /* pow(3) */ 48 printf("pow(2, 7)\t128.0\t\t%.1f\n", pow(2, 7)); 49 printf("pow(9, .5)\t3.0\t\t%.1f\n", pow(9, .5)); 50 printf("\n"); 51 52 /* fmod(3) */ 53 printf("fmod(13.657, 2.333)\t1.992\t%.3f\n", fmod(13.657, 2.333)); 54 printf("\n"); 55 56 /* sin(3) */ 57 printf("sin(0.0)\t0.0\t\t%.1f\n", sin(0.0)); 58 printf("\n"); 59 60 /* cos(3) */ 61 printf("cos(0.0)\t1.0\t\t%.1f\n", cos(0.0)); 62 printf("\n"); 63 64 /* tan(3) */ 65 printf("tan(0.0)\t0.0\t\t%.1f\n", tan(0.0)); 66 printf("\n"); 67 68 return 0; 69 } /* E0F main */ 70