Question: Problem 6 ( Decimal - Binary Lookup Table ) Write a program named dec 2 bin table.cpp that prompts to users to enter a non

Problem 6(
Decimal - Binary Lookup Table
)
Write a program named
dec2bin
table.cpp
that prompts to users to enter a non-negative
integer
N
from the keyboard. Displays a binary lookup table that contains all binary rep-
resentations from 0 to
N
. Your program should report the message
Invalid value of
N
if
N
0
/workspace/csc117/hw7
% g++-o out/dec2bin_table.out src/dec2bin_table.cpp
%./out/dec2bin_table.out
Enter the value of N: 9
00
11
210
311
4100
5101
6110
7111
81000
91001
4
%./out/dec2bin_table.out
Enter the value of N: -4
Invalid value of N
Hints
:
Create a loop running from 0 to
N
. At the iteration
i
, finds binary representation of
i
and displays it to standard output.
Use previous homeworks solution to convert a decimal value to binary
Use
\
t
as a separator of the two columnn

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!