Question: Example 12: Draw a flowchart to receive a positive number (in base 10) and output its binary representation (base 2). You are not allowed to

 Example 12: Draw a flowchart to receive a positive number (in

Example 12: Draw a flowchart to receive a positive number (in base 10) and output its binary representation (base 2). You are not allowed to use any built-in function to convert the number-such as parseInt() or any other function. Instead, you should use some loops and convert the number through a computational process. Recall, to convert a number from base 10 to base 2, you should keep dividing it by 2 and use the remainders to build its representation in base 2. For instance, to convert 38 from base 10 to base 2: quotient remainder 38/2 is 19 and 38 mod 2 is 0 iteration 1 19/2 is and 19 mod 2 is 1 iteration 2 9/2 is and 9 mod 2 is 1 iteration 3 4/2 is and 4 mode 2 is iteration 4 2/2 is and 2 mode 2 is 0 iteration 5 1/2 is and 1 mode 2 is 1 iteration 6 the answer is 1 0 0 1 1 0 So, the loop continues until the quotient is 0

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 Databases Questions!