Functions and Recursions – Arithmetic – Problem #9

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: hard

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

Back to Lab Problems
Functions and Recursions/Arithmetic/Problem #9

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #9

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.