from my previous program program penghitung uang pecahan dengan python i've rewrite the code in C
#include <stdio.h> /*change currency counter program*/ int main(){ int amount, result, rest; /*user input*/ printf ("welcome to amount currency counter program \n"); printf ("input your amount change "); scanf ("%d", &amount); /*mulai proses*/ result=amount/100000; rest=amount%100000; printf ("your change amount : \n"); printf ("%d", result); printf(" seratusribuan \n"); if (rest>=50000){ result=rest/50000; rest=rest%50000; printf("%d", result); printf(" limapuluhribuan \n"); } if (rest>=20000){ result=rest/20000; rest=rest%20000; printf("%d", result); printf(" duapuluhribuan \n"); } if (rest>=10000){ result=rest/10000; rest=rest%10000; printf("%d", result); printf(" sepuluhribuan \n"); } if (rest>=5000){ result=rest/5000; rest=rest%5000; printf("%d", result); printf(" limaribuan \n"); } if (rest>=1000){ result=rest/1000; rest=rest%1000; printf("%d", result); printf (" seribuan \n"); } if (rest>=500){ result=rest/500; rest=rest%500; printf("%d", result); printf (" limaratusan \n"); } if (rest>=100){ result=rest/100; rest=rest%100; printf("%d", result); printf (" seratusan \n"); } getchar(); return 0; } |
No comments:
Post a Comment