Here is a program that calculates the amount of change in a given sum. I believe this might point you in the right direction for what you are doing.
Code:
#include <stdio.h>
#include <math.h>
void change(float, int*, int*, int*, int*); //function prototype
int main(void){
float fMoney;
int iQuarters, iDimes, iNickels, iPennies;
//Prompt for money entry
printf("Enter how much money you wish to convert to change: ");
scanf("%f", &fMoney);
//call our function to perform conversion
change(fMoney, &iQuarters, &iDimes, &iNickels, &iPennies);
//Display result
printf("\nYou have %d quarters, %d dimes, %d nickels, and %d
pennies\n", iQuarters, iDimes, iNickels, iPennies);
return(0);
}
//provide our function definition
void change(float fMoney, int* iQuart, int* iDime,
int* iNick, int* iPenn) {
//Determine how many quarters, dimes, nickels and pennies are in the money provided
*iQuart = (int)(fMoney / .25);
fMoney = fMoney - (.25 * *iQuart);
*iDime = (int)(fMoney / .10);
fMoney = fMoney - (.10 * *iDime);
*iNick = (int)(fMoney / .05);
fMoney = fMoney - (.05 * *iNick);
*iPenn = ceilf(fMoney*100); //ceilf used to counter rounding error experienced with floating point numbers
}
Happy Coding!!