Functions and Recursions – Arithmetic – Problem #9
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a C program using recursive functions to compute the binary equivalent for a given deci- mal fractional number. [Hint: In the first step, separate integer and decimal parts of a given decimal fractional num- ber. For each part write a separate C recursive function. void int to bin(int, int[ ]), void frac to bin(int, int[ ]). Consider the max size of the array is 16 for storing the binary equivalents of integer and fractional parts. While printing the binary equivalent of a given decimal fractional number in the main(), only required portions of binary digits to be displayed.] Example: Enter a decimal number 13.625 integer part 13 decimal part 0.625000 Binary equivalent: 1101.101