I started on this exercise around 9:30 or 10 this morning (though it has taken so long partially due to the nature of being at work and actually having to... well... work). The exercise is to write a program that will take an original dollar amount, and split it into twenties, tens, fives, and ones.
Oh man. When I wrote it the first time? I thought I had too many variables to begin with, so I tried to make the variables I had do crazy things. I should have saved it. I can't remember exactly what I did, but it ended up with hilarious answers like:
$20 bills: 3
$10 bills: 0
$5 bills: -13
$1 bills: -137
I couldn't help but laugh and delete the whole thing, ahahaha...
After tweaking and pouring over my graphing calculator and a few paper scraps with notes on them, I did get it working though! As of 11:45, here is my working USD splitting program:
#include <stdio.h>
#define twenty 20
#define ten 10
#define five 5
#define one 1
int main (void)
{
int original_amount;
int twenty_bills, ten_bills, five_bills, one_bills;
int orig_after_twen, orig_after_ten, orig_after_five;
printf("Please enter the original dollar amount: ");
scanf("%d", &original_amount);
twenty_bills = original_amount/twenty;
orig_after_twen = original_amount - (twenty_bills * twenty);
printf("$20 bills: %d\n", twenty_bills);
ten_bills = orig_after_twen/ten;
orig_after_ten = orig_after_twen - (ten_bills * ten);
printf("$10 bills: %d\n", ten_bills);
five_bills = orig_after_ten/five;
orig_after_five = orig_after_ten - (five_bills * five);
printf("$5 bills: %d\n", five_bills);
one_bills = orig_after_five/one;
printf("$1 bills: %d\n", one_bills);
return 0;
}