This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Every time I try to run it Spits out zero help me !
include <cs50.h>
include <stdio.h>
int get_cents(void); int calculate_quarters(int cents); int calculate_dimes(int cents); int calculate_nickels(int cents); int calculate_pennies(int cents);
int main(void) { int cents = get_cents();
int quarters = calculate_quarters(cents);
cents = cents - quarters * 25;
int dimes = calculate_dimes(cents);
cents = cents - dimes * 10;
int nickels = calculate_nickels(cents);
cents = cents - nickels * 5;
int pennies = calculate_pennies(cents);
cents = cents - pennies * 1;
int coins = quarters dimes nickels pennies;
printf("%i\n", coins);
}
int get_cents(void) { int cents; do { cents = get_int("Enter money "); } while (cents > 0); return cents; } int calculate_quarters(int cents) { int quarters = 0;
while (cents >= 25)
{
quarters = 1 quarters;
cents = cents - 25;
}
return quarters;
} int calculate_dimes(int cents) { int dimes = 0;
while (cents >= 10)
{
dimes = 1 dimes;
cents = cents - 10;
}
return dimes;
}
int calculate_nickels(int cents) { int nickels = 0;
while (cents >= 5)
{
nickels= 1 nickels;
cents = cents - 5;
}
return nickels;
}
int calculate_pennies(int cents) { int pennies = 0;
while (cents >= 1)
{
pennies = 1 pennies;
cents = cents - 1;
}
return pennies;
}
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/cs50/commen...