Trying to figure out how the coin denominations are computed.
Code:
// Import libraries
#include <stdio.h>
#include <math.h>
#include <cs50.h>
int main()
{
// Define an int type variable
int coins_due;
// Create a 'do while' loop
do
{
float change_owed = get_float("Change owed: ");
coins_due = round(change_owed * 100);
}
while (coins_due <= 0);
int quarters = coins_due / 25;
int dimes = (coins_due % 25) / 10;
int nickels = ((coins_due % 25) % 10) / 5;
int pennies = ((coins_due % 25) % 10) % 5;
// Print output
printf("Coins due: %d\n", quarters + dimes + nickels + pennies);
}