There are many ways to remove the extra zeros.
Easiest way is to use
%gas the format specifier in the
printf("%g",a/b);. This is remove the extra zeros after the decimal.
You can use
printf("%.0d%.4g\n", (int)(a/b)/10, (a/b)-((int)(a/b)-(int)(a/b)%10));.
You can use a separate function to remove the extra zeros but it is a tedious process. First transfer all the digits to a string and remove the unwanted zeros from the end.
You can also use
%.2fformat specifier to reduce the zeros. Eg.
printf("%.2f",a/b);– this can be used where you want to print the exact number of digits after the decimal point.
%.<the number of digits to be printed after decimal point>f.
CLICK HERE to find out more related problems solutions.