Exemple #1
0
int main(void)
{
	int cash, twenties, tens, fives, ones;
	printf("Enter the amount of money: ");
	scanf("%d", &cash);
	pay_amount(cash, &twenties, &tens, &fives, &ones);
	printf("$20 bills: %d\n", twenties);
	printf("$10 bills: %d\n", tens);
	printf("$5 bills: %d\n", fives);
	printf("$1 bills: %d\n", ones);
	return 0;
}
Exemple #2
0
int main (int argc, char** argv)
{
    // Check command line arguments
    if (argc < 2) {
        fprintf(stderr, "Usage: ./pay-help amount\n");
        return EXIT_FAILURE;
    }

    // Initialize variables
    int amount = atoi(argv[1]);
    int twenties, tens, fives, ones;

    pay_amount(amount, &twenties, &tens, &fives, &ones);

    printf("$20 bills: %d\n$10 bills: %d\n $5 bills: %d\n $1 bills: %d\n",
        twenties, tens, fives, ones);

	return EXIT_SUCCESS;
}
Exemple #3
0
int main()
{
    //declare variables
    int dollars;
    int twenties, tens, fives, toonies, loonies;

    //prompt user for input & check
    do
    {
        printf(">> How much money do you have: ");
        scanf("%d", &dollars);
    }while(dollars < 0);

    //call function
    pay_amount(dollars, &twenties, &tens, &fives, &toonies, &loonies);

    //display a pretty breakdown
    printf(">> Twenties:\t%d\n", twenties);
    printf(">> Tens:\t%d\n", tens);
    printf(">> Fives:\t%d\n", fives);
    printf(">> Toonies:\t%d\n", toonies);
    printf(">> Loonies:\t%d\n", loonies);
}