I've wrote the following which passes check50 and operates as intended:
#include <stdio.h> #include <cs50.h> #include <math.h>
int cents = round(change * 100);
I've looked at the round reference here and it references a "double round". Everything seems to be in order, but I implemented neither the double round nor the "%i.55" as indicated in the Hints section here.
I understand the need to round the float and assign the variable then as an integer. But, I am only guessing that the double round has to do with currency formatting (i.e., two decimal places) and that the "%i.55" bits have to do with preventing runtime errors if the user inputs outrageously high figures. Or am I completely off? As I've stated it passes the automated check50 but I'd like to have a firm grasp on this before submitting and moving on in the course. Thanks in advance.