1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#pragma warning (disable:4996)
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int dispense(int amount, int *ptwenty, int *pten, int *pfive);
int main(void)
{
int amount;
int dispense(int, int, int, int);
int ones;
int ten;
int twenty;
int five;
ones = dispense(amount, &twenty, &ten, &five);
printf("%s\n","*****Welcome to Central Banking ATM*****");
printf("%s\n","Enter the amount you'd like to withdraw: ");
printf("%s\n","NOTE: It must be a multiple of 5.");
scanf("%d",&amount);
printf("%s%d\n","Number of 20s: ",twenty);
printf("%s%d\n","Number of 10s: ",ten);
printf("%s%d\n","Number of 5s: ",five);
printf("%s\n","Thank you for your business!");
return 0;
}
int dispense(int amount, int *ptwenty, int *pten, int *pfive)
{
int amt = amount;
*ptwenty = amt / 20;
amount = amt % 20;
*pten = amt / 10;
amount = amt % 10;
*pfive = amt / 5;
return amt % 5;
}
|