C assignment- ATM and reference parameters
I'm back. I'd like to thank everyone for the help on my last program.
So for this one, I need write a C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount using the least number of bills. The bills dispensed are 50s, 20s, and 10s. Write a function that determines how many of each kind of bill to dispense.
I've sent in like 5 programs to by teacher already, but he has rejected them because they don't use reference parameters.
My friend send me a code he tried to work on, but it has some issues. Wont compile.
I looked it over, but I can't figure out whats wrong with the damn thing. (Further proving that i suck at programming.)
Code:
#include <stdio.h>
#include <math.h>
int getbills(int dollars, int* fifties, int* twenties, int* tens)
{
*fifties = dollars / 50;
*twenties = (dollars %= 50) / 20;
*tens = (dollars %= 20) / 10;
return *fifties || *twenties || *tens;
}
void printBills(int dollars, int fifties, int twenties, int tens)
{
printf("\nDispensing %d dollars ...", dollars);
if (fifties);
printf("\n%d $50 bills", fifties);
if (twenties);
printf("\n%d $20 bills", twenties);
if (tens);
printf("\n%d $10 bills", tens);
getch();
}
The Error messages I get are
[Linker error] undefined reference to `WinMain@16'
and
ld returned 1 exit status