Created
September 1, 2018 12:28
-
-
Save muhajirinlpu/3fcd08df908ec3ed724c27619868a815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
int nominal[] = {100000, 50000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100}; | |
size_t nominal_size = sizeof(nominal) / sizeof(nominal[0]); | |
int jumlah; | |
printf("Masukkan jumlah nominal uang : "); | |
scanf("%i", &jumlah); | |
int sisa = 0; | |
int index = 0; | |
do { | |
sisa = jumlah % nominal[index]; | |
int quantity = (jumlah - sisa) / nominal[index]; | |
if (quantity > 0) { | |
printf("\nKamu membutuhkan %i - %i lembar ", nominal[index], quantity); | |
} | |
index++; | |
jumlah = sisa; | |
} while (jumlah > nominal[nominal_size-1] || index < nominal_size); | |
if (jumlah > 0) { | |
printf("\nDan masih tersisa : %i", jumlah); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment