1st time posting...
touched up on ur programming, it was a rushed job...
doesnt really work (i.e. if u put 0 items on the 2nd or 3rd time round, it wont close.. read my notes at the end of the program. hope it helps u.
Code:
#include <stdio.h>
int main()
{
int numItems;
float price, amtPaid, total = 0, change;
int quarters = 10, dimes = 10, nickels = 10, pennies = 10, count;
printf("Please enter the number of grocery items: ");
scanf("%d",&numItems);
while(numItems != 0) /* main while loop, makes sure your program works only if numItems not equal to 0.*/
{
count = 0;
/*2nd loop, causes your program to ask repeatedly for the prices of your items, until numItems is met. */
while(count<numItems)
{
printf("Please enter the price for your item>");
scanf("%f", &price);
total += price;
count++;
}
printf("\n\nPlease enter the amount paid: ");
scanf("%f",&amtPaid);
change = amtPaid - total;
printf("\nChange is %.2f\n", change);
/* I don't understand your convertions */
quarters = change / .25;
dimes = change / .10;
nickels = change / .05;
pennies = change / .01;
/*convertions... . */
printf("The coins returned are: \n %d Quarters \n %d Dimes \n %d Nickels \n %d Pennies.\n", quarters, dimes, nickels, pennies);
total = 0;
}
return 0;
} /*end function main*/
//note on my program, you have to use a clr memory function, search around the forums. you have to clr up
//the 'numItems' variable at the end of the loop good luck hahahah.
//and ther may be errors, i rushed thru it. but yes, u get the rough idea.
ahha, hope it posts right, i dont even know the tags ...