fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int amount;
  5. printf("จำนวนเงิน: ");
  6. scanf("%d", &amount);
  7.  
  8. printf("10 บาท: %d\n", amount / 10);
  9. amount %= 10;
  10. printf("5 บาท: %d\n", amount / 5);
  11. amount %= 5;
  12. printf("2 บาท: %d\n", amount / 2);
  13. amount %= 2;
  14. printf("1 บาท: %d\n", amount);
  15.  
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0.03s 25968KB
stdin
Standard input is empty
stdout
#include <stdio.h>

int main() {
    int amount;
    printf("จำนวนเงิน: ");
    scanf("%d", &amount);

    printf("10 บาท: %d\n", amount / 10);
    amount %= 10;
    printf("5 บาท: %d\n", amount / 5);
    amount %= 5;
    printf("2 บาท: %d\n", amount / 2);
    amount %= 2;
    printf("1 บาท: %d\n", amount);

    return 0;
}