#include <stdio.h>
#include <conio2.h>
void hitung(int amount, int *denom100, int *denom50, int *denom20, int *denom10)
{
int restofmoney;
*denom100 = amount / 100000;
restofmoney = amount - (*denom100 * 100000);
*denom50 = restofmoney / 50000;
restofmoney = restofmoney - (*denom50 * 50000);
*denom20 = restofmoney / 20000;
restofmoney = restofmoney - (*denom20 * 20000);
*denom10 = restofmoney / 10000;
}
int periksa(int amount)
{
if(amount % 10000 == 0)
{
return 1;
}
else return 0;
}
int main ()
{
int amount,
denom100 = 0,
denom50 = 0,
denom20 = 0,
denom10 = 0;
printf("Jumlah uang: "); scanf("%d", &amount);
if(periksa(amount))
{
hitung(amount, &denom100, &denom50, &denom20, &denom10);
printf("%d lembar Rp100.000,-\n", denom100);
printf("%d lembar Rp 50.000,-\n", denom50);
printf("%d lembar Rp 20.000,-\n", denom20);
printf("%d lembar Rp 10.000,-\n", denom10);
}
else printf("Tidak dapat dipecah");
getch();
return 0;
}
|
0 komentar:
Post a Comment