We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
double meal;
float tax,tip;
int total;
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
scanf("%lf",&meal);
scanf("%e",&tip);
scanf("%e",&tax);
tip=meal*tip/100;
tax=meal*tax/100;
total=meal+tip+tax;
printf("The total meal cost is %d dollars.",total);
return 0;
in this code i do realize the error that i should round the number to nearest integer but im keen to know how float rounds up the number to next nearest integer.
moreover is it the only way to round the integer result?
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
in this code i do realize the error that i should round the number to nearest integer but im keen to know how float rounds up the number to next nearest integer. moreover is it the only way to round the integer result?