Hi folks, well I hope you all can help guide me in the right direction. I have an assignment for a C class that requires a function named change() that accepts a single precision numeber and the address of the integer variables named quarters,dimes, nickels, pennies. The function is supposed to determine the number of quarters, dimes, nickels and pennies in the number passed to it and write the values back into the respective variables in it's calling function.
I am stuck on the syntax on how to take the input number and let it be broken down into the appropriate values asked for. Also I was wanting to write some additional code to randomly generate these values as a seperate function When entering a specific value at the start.
Here is what i have so far, nothing fancy, not very clean, but I can't find any other resource right now.
Please if anyone has any feedback that will help, please e-mail me with soe feedback. I'm not looking for anyone to write the rest for me, but some good direction would be nice. Thanks to all who help.
// Change function.cpp : Defines the entry point for the console application.
int _tmain(int argc, _TCHAR* argv);
void change (float *, float *,float *,float *,float *);
float total, quarters, dimes, nickels, pennies;
quarters = .25;
dimes = .10;
nickels = .05;
pennies = .01;
printf("Enter dollar amount to be converted into change\n\n");
printf("\nThe number you entered is stored in a variable named \"total\"\n");
printf("The address of \"total\" will be %u\n\n", &total);
printf("Other variables named \"quarters\",\"dimes\",\"nickels\",and \"pennies\" will be stored\n");
printf("in the following addresses\n\n");
printf("quarters address = %u\n", quarters);
printf("dimes address = %u\n", dimes);
printf("nickels address = %u\n", nickels);
printf("pennies address = %u\n", pennies);
change(&total, &quarters, &dimes, &nickels, &pennies);
void change(float *totalchange, float *quarters, float *nickels, float *dimes, float *pennies)
printf("\nThe number you entered is %.2f\n\n", *totalchange);
printf("Quarters are worth %.2f cents\n", *quarters);
printf("Dimes are worth %.2f cents\n", *dimes);
printf("Nickels are worth %.2f cents\n", *nickels);
printf("Pennies are worth %.2f cents\n\n", *pennies);
printf("A randmomly generated value of quarters, dimes, nickels and pennies is\n");
printf("displayed below totaling the amount you entered earlier\n\n");