I need to break down the amounts on their respective bill/coin. The output is somewhat like this: So far, here is my code: (I made the last few codes a comment one 'cos the errors come from there) #include <stdio.h> #include <conio.h> #include <math.h> main() { int x,y; printf("Enter input: "); scanf("%d",&x); y=x/1000; printf("\nNo. of P1000 bill: %d",y); x = x%1000; y=x/500; printf("\nNo. of P500 bill: %d",y); x = (x%500); y=x/200; printf("\nNo. of P200 bill: %d",y); x = (x%200); y=x/100; printf("\nNo. of P100 bill: %d",y); x = (x%100); y=x/50; printf("\nNo. of P50 bill: %d",y); x = (x%50); y=x/20; printf("\nNo. of P20 bill: %d",y); x = (x%20); y=x/10; printf("\nNo. of P10 coin: %d",y); x = (x%10); y=x/5; printf("\nNo. of P5 coin: %d",y); x = (x%5); y=x/1; printf("\nNo. of P1 coin: %d",y); x = (x%1); //y=x/.25; //printf("\nNo. of 25 cents: %d",y); //x = (x%.25); //y=x/.01; //printf("\nNo. of 1 cent: %d",y); //x = (x%.01); getch(); return 0; } Code (markup): I hope you'll help me out with this. :/ Thanks!
When you get to the last 2 calculations - for .25 and .01, multiply x by 100 and work in cents not dollars so that you are still working in integer math.