Problem1602--C Programming Practicals 5-5

1602: C Programming Practicals 5-5

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 425  Solved: 155
[Submit] [Status] [Web Board] [Creator:]

Description

Write a C code to convert decimal integer number to binary using a user defined function.Info: How to convert decimal to binary: 1.Divide the decimal number by 2. 2.Get the integer quotient for the next iteration. 3.Get the remainder for the binary digit. 4.Repeat the steps until the quotient is equal to 0.

Input

Enter a decimal number: 5

Output

Step 1: 5/2, Remainder = 1, Quotient = 2 Step 2: 2/2, Remainder = 0, Quotient = 1 Step 3: 1/2, Remainder = 1, Quotient = 0 5 (decimal) = 101 (binary)

Sample Input Copy

5

Sample Output Copy

Step 1: 5/2, Remainder = 1, Quotient = 2
Step 2: 2/2, Remainder = 0, Quotient = 1
Step 3: 1/2, Remainder = 1, Quotient = 0
5 (decimal) = 101 (binary)

Source/Category

130