You are viewing a single comment's thread. Return to all comments →
you should declare total cost as float and then print it like this
printf("the total cost is %.0f dollars",round(total_cost));
the round function will round the value of total cost to nearest integer and then diplay it without decimals.
You should use %.0f otherwise the cost will be rounded to nearesr integer but will be printed like 15.0000 so to avoid decimal use %.0f
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
you should declare total cost as float and then print it like this
printf("the total cost is %.0f dollars",round(total_cost));
the round function will round the value of total cost to nearest integer and then diplay it without decimals.
You should use %.0f otherwise the cost will be rounded to nearesr integer but will be printed like 15.0000 so to avoid decimal use %.0f