/* ECP: FILEname=fig1_2.c */ /* 1*/ #include /* 2*/ /* Read Items, Compute Their Average */ /* 3*/ main( void ) /* 4*/ { /* 5*/ int ItemsRead = 0; /* 6*/ double ThisItem, Sum = 0.0; /* 7*/ printf( "Enter as many items as you want\n" ); /* 8*/ printf( "Terminate with non-double or EOF marker\n" ); /* 9*/ while( scanf( "%lf", &ThisItem ) == 1 ) /*10*/ { /*11*/ ItemsRead++; /*12*/ Sum += ThisItem; /*13*/ } /*14*/ printf( "The average of %d items was %f\n", /*15*/ ItemsRead, Sum / ItemsRead ); /*16*/ return 0; /*17*/ }