There is something wrong with the last printf statement, (double)(a/b). Before the conversion, a/b operation has been carried out, because both A and B are of int type, so the result of division is also of int type (rounding). When they are converted into double type, the decimal part has become 0, and (double)a/b is to convert A into double type and then divide by B.
For example: (double)( 1/2), the result of 1/2 is 0, and (double)( 1/2) is 0.000000.
(double) 1/2 is actually 1.000000/2, and the result is 0.500000.