Question: write the code in python Example binary conversion: 22/2 11 r 0 (this remainder is the least significant binary digit) 11/2=5r1 5/2=2r1 2/2=1r0 1/2=0r1 pulling

write the code in python
Example binary conversion: 22/2 11 r 0 (this remainder is the least  

Example binary conversion: 22/2 11 r 0 (this remainder is the least significant binary digit) 11/2=5r1 5/2=2r1 2/2=1r0 1/2=0r1 pulling all the remainders together we get 10110 [check: 16 +4 + 2 = 22] THE PROBLEM: Write a program that takes in a positive integer as input, and outputs a string of 1's and O's representing the integer in binary. For an integer x, the algorithm is: LOOP: As long as x is greater than 0 comment: The conversion naturally starts at the least significant digit. To put the binary digits in the correct order, pre-pend each binary digit to a string that starts out empty. LOOP: OutputString x modulo 2 (remainder is either 0 or 1) + OutputString Assign x with x divided by 2 and repeat EXAMPLE OUTPUT: This program converts a user entered decimal number to binary. Enter a positive integer to convert to binary (0 or less to QUIT): 1 1 is 1 binary

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!