menghitung jumlah mata uang ~ Ivul varel

menghitung jumlah mata uang

#include <stdio.h>
#include <stdlib.h>

int main(){

  int n[14]={100000, 50000, 20000, 10000, 5000, 1000, 500, 200, 100, 50, 25, 10, 5, 1}, x, y, z, p=0;
  printf("Jumlah Uang : ");
  scanf("%d", &x);

  printf("\nOutput:\n");
  printf("----------------------\n");
  printf("pecahan\t\tJumlah\n");
  printf("----------------------\n");
{
for (y=0 ; y<=13 ; y++)
 if (x >= n[y])
{
z = x / n[y];
x = x % n[y];
        printf("%d\t\t%d\n", n[y], z);
}
else
  printf("%d\t\t%d\n", n[y], p);
  printf("----------------------\n");
}
return 0;
}
Previous
Next Post »
Post a Comment
Thanks for your comment