I am currently taking the cs50 Harvard course via EDX and am working on the Cash/Greedy Algorithm problem from PSET1/Week1. I have it all written out and I keep getting this error;
~/pset1/ $ clang -o cash cash.c -lcs50
/tmp/cash-4f9816.o: In function `main':
cash.c:(.text+0x44): undefined reference to `round'
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my code.
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
float dollars;
do
{
dollars = get_float("Change: ");
}
while (dollars <= 0);
int cents = round(dollars * 100);
int coins = 0;
while (cents >= 25)
{
coins ++;
cents -= 25;
}
while (cents >= 10)
{
coins ++;
cents -= 10;
}
while (cents >= 5)
{
coins ++;
cents -= 5;
}
while (cents >= 1)
{
coins ++;
cents -= 1;
}
printf("You Will Receive %i Coin(s)\n)", coins);
}
Can someone help me figure this out without breaking the Harvard honor code?