I am currently working on the pset1 greedy (cash) project. I am so close to finishing and I only have one more thing to complete before I can submit it as correct. I am working on rounding the initial cash amount up, but when I use round or roundf, I just get this error: implicitly declaring library function 'roundf' with type 'float (float)'
What could be wrong with my code? Here it is:
#include <cs50.h>
#include <stdio.h>
// Main Function
int main(void)
{
int cash;
float c = 100;
// Asks User for dollar amount
do
{
printf("How much money do you have?\n");
c = get_float();
cash = roundf(c * 100);
}
while (c < 0);
// Total coin float
int coins = 0;
// Coin Values
cash = c * 100;
float quarter = 25;
float dime = 10;
float nickel = 5;
float penny = 1;
// Quarters
while (cash >= quarter) {
coins++;
cash = cash - quarter;
}
// Dimes
while (cash >= dime) {
coins++;
cash = cash - dime;
}
// Nickels
while (cash >= nickel) {
coins++;
cash = cash - nickel;
}
// Pennies
while (cash >= penny) {
coins++;
cash = cash - penny;
}
// Print how many coins there are
printf("%i\n", coins);
}
Thanks for the help and have a wonderful day!