Question

Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary.

#In Coral  

CHALLENGE ACTIVITY 7.1.1: Convert to binary. 

 Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:

 As long as x is greater than e

 Output x % 2 (remainder is either e or 1)

 x= x / 2

 Note: The above algorithm outputs the O's and 1's in reverse order.

 Ex: If the input is 6, the output is:

 011

 (6 in binary is 110; the algorithm outputs the bits in reverse).


0 0
Add a comment Improve this question Transcribed image text
Answer #1

if you like the answer please provide a thumbs up.

Add a comment
Know the answer?
Add Answer to:
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT