0
#include <cs50.h>
#include <stdio.h>
#include <math.h> 


int main (void)
{
    float dollar;
    do
    {
         dollar = get_float("Enter your change");
    }
    while (dollar<=0);

    int cents = round (dollar*100);

    int coins=0;
    while (cents>=25)
    {
         cents-=25;
         coins++;
    }

    while (cents>=10)
    {
        cents-=10;
        coins++;
    }


    while (cents>=5)
    {
        cents-=5;
        coins++;
    } 
    while (cents>=1)
    {
        cents-=1;
        coins++;
    }

    printf ("You will need at least %i coins", coins);
}
/tmp/cash-0381f2.o: In function `main':


cash.c:(.text+0x1c): undefined reference to `get_float'


cash.c:(.text+0x44): undefined reference to `round'


clang: error: linker command failed with exit code 1 (use -v to see invocation)

What does this mean?

2
  • Could you just put the part of the terminal? – Vsjain Nov 11 '20 at 5:29
  • It likely means your setup is not linking the libraries properly. Go through the lectures to see other methods you can use to run your code and copy the error message if any. The line of code ``` int cents= round (dollar*100); ``` could be a problem. It is best to declare a variable and initialise it (to 0 in this case) before using it. – EddyBeor Dec 9 '20 at 20:05

You must log in to answer this question.

Browse other questions tagged .