/* week_wage.c - Len Meakin - 13-12-00 */ #include #include int number_of (int amount, long *wage); int main (void) { float wage = 0.0; int num_of[10][2] = { {2000 , 0}, {1000 , 0}, { 500 , 0}, { 100 , 0}, { 50 , 0}, { 20 , 0}, { 10 , 0}, { 5 , 0}, { 2 , 0}, { 1 , 0}}, counter = 0; long int_wage = 0; do{ printf("Enter employee's wage (0 to quit) - "); scanf("%f", &wage); /*Quit program if 0 was entered*/ if ( !wage ) return EXIT_SUCCESS; /*Get the wage as an integer value*/ int_wage = wage * 100 + 0.1; for( counter = 0 ; counter < 10 ; counter++ ) num_of[counter][1] = number_of( num_of[counter][0] , &int_wage); for( counter = 0 ; counter < 10 ; counter++) (counter < 4) ? printf("No. of œ%2d notes = %d\n", num_of[counter][0] / 100 , num_of[counter][1]) : printf("No. of %2dp coins = %d\n", num_of[counter][0], num_of[counter][1]); }while(wage != 0); return EXIT_SUCCESS; } int number_of (int amount, long *wage) { int num = 0; long remainder = 0; remainder = *wage % amount; num = *wage / amount; *wage = remainder; return num; }