Help, home work code provided. Totally Lost.
Okay first of all thank you for looking at this I know HW questions can be pain staking.
Here is the question posted and i did searches in the forum and with no results to help.
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
Here is what I have.
Code:
#include <stdio.h>
#include <math.h>
int main()
{
float quarters, nickels, dimes, pennies, total;
int final;
char stopprogram;
void change (quarters, nickels, dimes, pennies, total);
total=1.88;
printf("The Total Entered: %f\n",total);
printf("%d quarters\n", quarters);
printf("%d nickels\n", nickels);
printf("%d dimes\n", dimes);
printf("%d pennies\n\n", pennies);
void change (quarters, nickels, dimes, pennies, total);
total=.32;
printf("The Total Entered: %f\n",total);
printf("%d quarters\n", quarters);
printf("%d nickels\n", nickels);
printf("%d dimes\n", dimes);
printf("%d pennies\n\n", pennies);
printf("Please enter a monetary value");
scanf("%f", &total);
void change (quarters, nickels, dimes, pennies, total);
printf("The Total Entered: %f\n",total);
printf("%d quarters\n", quarters);
printf("%d nickels\n", nickels);
printf("%d dimes\n", dimes);
printf("%d pennies\n", pennies);
scanf("%c", &stopprogram);
return 0;
}
float change (*quarters, *nickels, *dimes, *pennies, *total);
{
valuequarter=.25
valuedime=.10
valuenickel=.05
valuepenny=.01
*quarters= truncf(*total/valuequarter);
*total=*total-*quarters;
*dimes=truncf(*total/valuedime);
*total=*total-*dimes;
*nickels=truncf(*total/valuenickel);
*total=*total-*nickels;
*pennies=truncf(*total/valuepenny);
*total=*total-*pennies;
return 0;
}