1

hi i'm trying to convert the users input from dollars to cents. every time it just prints exactly what i typed in, so if i enter 0.20, the output is 0.200000. my math.h seems to be having no effect but i cannot see why.

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

int main(void)

{
    float dollars;
    int counter;
    int change;
    
    do
    {
        dollars = get_float("How much change? ");     //prompts for amount of change
    }
    while (dollars < 0);    //checks for positive sum
    
    change = roundf(dollars * 100);
        
    printf("%i\n", change);

}

2 Answers 2

0

You are typing roundf which is not correct. It isround() declared in math.h header file

0

seemed to be a compiling issue and nothing i was doing was being updated despite running 'make cash' about 100 times. reloaded browser and works fine

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .