Become a Member
 

Write a C++ program to output the binary

Write a C++ program to output the binary (base-2) representation of a decimal integer. The algorithm for this conversion is to be repeated dividing the decimal number by 2 until it is 0. Each division produces a remainder of 0 or 1 which becomes a digit in the binary numbers.

example the decimal number 25

25/2 = 12 remainder 1
12/2 = 6 remainder 0
6/2 = 3 remainder 0
3/2 - 1 remainder 1
1/2 = 0 remainder 1

Solution Summary

Write a C++ program to output the binary (base-2) representation of a decimal integer.

$2.19
This answer includes:
  • Plain text
  • Cited sources when necessary
  • Attached file(s)
    • 130836.cpp
Add to Cart   $2.19

Yupei Xiong, PhD

Rating 4.8/5

Active since 1969

BSc, Peking University
MA, Peking University
PhD, University of Maryland - College Park Campus

Responses 4195


Comments on Yupei's work:

"Thank you! u=sqrt(x) >0 was really a great reasoning. Thanks!"

"Can you check question# 8-13-15-18-19 for me, I just want to make sure... because Im different type of errors Thank you!"

"Did you have these codes before or you just created them this morning?"

"Hi.. thank you for the code. Can you also include this: =>Use HTML5 comments and CSS comments in the respective files to explain the code you have used. Unexplained code will be interpreted as possible evidence of plagiarism."

"Very helpful! and very good explanations which will be helpful in preparation for my exams."