Thought I'd ask you fine gentlemen and women another question, since my last one was answered to perfectly.
I basically just need to make a program with C that asks the USER to input a cost, and subtract it from one hundred.
It's also suppose to have 5 dollars, nickels and quarters. It's easy enough I know, but I, for the life of me, can't get passed 2 dollars. I can have it tell me how many Twenties, Tens and Fives they need to give back, but after that, I'm just incredibly stumped.
This is what I have so far, this is my 3rd attempt, writing the code more clearly from my other attempts.
If someone could show me how to just get the toonie, but nothing else. I just need a push in the proper direction, so I can than figure out the rest on my own.
Thanks in advance.
EDIT: Actually if I could get help for the cents instead, as I just figured out the toonie and loonie.. go figure.
I basically just need to make a program with C that asks the USER to input a cost, and subtract it from one hundred.
Enter the price of the purchase: $66.78
The change from $100.00 is: $33.22
Number of $20 bills is: 1
Number of $10 bills is: 1
Number of $2 coins is: 1
Number of $1 coins is: 1
Number of dimes is: 2
Number of pennies is: 2
It's also suppose to have 5 dollars, nickels and quarters. It's easy enough I know, but I, for the life of me, can't get passed 2 dollars. I can have it tell me how many Twenties, Tens and Fives they need to give back, but after that, I'm just incredibly stumped.
This is what I have so far, this is my 3rd attempt, writing the code more clearly from my other attempts.
Code:
#include <stdio.h>
int main(void)
{
int num;
int change;
int rea20; /*Remaining after Twenty*/
int rea10; /*Reamining after Ten */
int rea5; /*Reamining after five */
printf("Enter the price of the purchase in dollars ($100 or less): \n");
scanf("%d", &num);
printf("The change from $100 is: %d\n", 100 - num);
change = 100 - num;
printf("The number of $20 bills is: %d\n", change / 20);
rea20 = change % 20;
printf("The number of $10 bills is: %d\n", rea20 / 10);
rea10 = rea20 % 10;
printf("The number of $5 bills is: %d\n", rea10 / 5);
If someone could show me how to just get the toonie, but nothing else. I just need a push in the proper direction, so I can than figure out the rest on my own.
Thanks in advance.
EDIT: Actually if I could get help for the cents instead, as I just figured out the toonie and loonie.. go figure.