Function: convert to notes
The function need to cal. the no. of bank notes given a certain amount of money, it will calculate the number of hundred-dollar notes and twenty-dollar notes, given a certain amount of money, and also return the remaining amount of money not enough for a twenty-dollar note.
for example: $1278
the function should return 12 hundred-dollar notes
,3 twenty-dollar notes, and then 18 as the remaining amount.
Can someone look my code and check my syntax error, thk a lot.
Code:
struct notes {
int oneHundred;
int twenty;
int remainder;
};
void convertToNotes2(int money, struct notes* notes) {
(*notes).oneHundred=money/100; /* 1278 / 100 = 12 */
(*notes).twenty=(money-oneHundred*100)/20; /* (1278 - 12 x 100) / 20 = 3 */
(*notes).remainder=money-oneHundred*100-twenty*20; /* 1278 - 12 x 100 - 3 x 20 = 18 */
}