4atof.c (320B)
1 /* Exercise 8.8 */ 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 int main(void) 7 { 8 char s[8] = { 0 }; 9 int i; 10 float total = 0; 11 12 for(i = 0; i < 4; i++) { 13 printf("Give me a string (int?): "); 14 gets(s); 15 total += atof(s); 16 } 17 18 printf("The total is: %.2f\n", total); 19 20 return 0; 21 } /* E0F main */ 22