The old "making change" program
- From: "Chris" <cmlally@xxxxxxxxx>
- Date: 10 Jan 2006 03:36:15 GMT
Hi everybody,
My new C programming class is absolutely kicking my butt. I have not
been able to devote the time necessary to work on it at times, and am
now falling behind. This is the task I have been given:
Write a C function named change() that accepts a floating point number
of total coins and the addresses of the integer variables named
quarters, dimes, nickels, and pennies. The function should determine
the number of quarters, dimes, nickels, and pennies in the total coins
number passed to it and write these values directly into the respective
variables declared in its calling function using pointers.
Call the function change() from main() three times and print out the
contents of the variables quarters, dimes, nickels, and pennies after
each function return.
First Call--pass in the total value $1.88 and on return print the
contents of the variables.
Second Call--pass in the total value .32 and on return print the
contents of the variables.
Third Call--ask for a total value input from the keyboard and on return
print the contents of the variables.
Output should look like:
TOTAL VALUE ENTERED: 1.88
7 quarters
1 dime
0 nickels
3 pennies
and not:
TOTAL VALUE ENTERED: 1.88
7 quarters
18 dimes
37 nickels
188 pennies
I am not sure where to begin since they want multiple calls to the same
program. Please help.
--
comp.lang.c.moderated - moderation address: clcm@xxxxxxxxxxxx -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
.
- Follow-Ups:
- Re: The old "making change" program
- From: Johannes Weiner
- Re: The old "making change" program
- From: Jasen Betts
- Re: The old "making change" program
- From: WillerZ
- Re: The old "making change" program
- From: Roger Leigh
- Re: The old "making change" program
- From: Roger Leigh
- Re: The old "making change" program
- From: Francis Glassborow
- Re: The old "making change" program
- From: Kalle Olavi Niemitalo
- Re: The old "making change" program
- From: Keith Thompson
- Re: The old "making change" program
- From: Chuck F.
- Re: The old "making change" program
- From: Martin Ambuhl
- Re: The old "making change" program
- Prev by Date: Re: RECURSIVELY....Printing Vowels from a string
- Next by Date: Re: could anybody help me with this simple exercise?
- Previous by thread: Re: could anybody help me with this simple exercise?
- Next by thread: Re: The old "making change" program
- Index(es):
Relevant Pages
|