Write a C++ program for the conversion of a decimal number to a binary, octal and hexadecimal equivalents within a given range of the upper and lower limits. Your program needs to follow the following steps to give the desired output. (1.a). Your program should ask to choose the upper limit from 256, 128, 32, 16, 8, 4, 2 only. If a user enters a number other than these numbers, the program should display a message of wrong entry and should ask for retry, otherwise continue to step (b). (1.b). Your program should ask to enter the lower limit. The lower limit should be less than the upper limit (of step 1.a) and greater than 0. If a user enters a number greater than the upper limit or less than 0 (e.g., a negative value), then the program should display a message of wrong entry and should ask for retry, otherwise continue to display the output. (1.c). If a user enters the upper and lower limits correctly, then the program should print a table of the binary, octal and hexadecimal equivalents of the given decimal numbers in the range of upper and lower limits as given in screenshots. Use of while loop, if else, for loop, nested loops is allowed. Functions, arrays and goto statements are NOT allowed.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a C++ program for the conversion of a decimal number to a binary, octal and hexadecimal
equivalents within a given range of the upper and lower limits. Your program needs to follow the
following steps to give the desired output.
(1.a). Your program should ask to choose the upper limit from 256, 128, 32, 16, 8, 4, 2 only. If a
user enters a number other than these numbers, the program should display a message of wrong
entry and should ask for retry, otherwise continue to step (b).
(1.b). Your program should ask to enter the lower limit. The lower limit should be less than the
upper limit (of step 1.a) and greater than 0. If a user enters a number greater than the upper limit
or less than 0 (e.g., a negative value), then the program should display a message of wrong entry
and should ask for retry, otherwise continue to display the output.
(1.c). If a user enters the upper and lower limits correctly, then the program should print a table of
the binary, octal and hexadecimal equivalents of the given decimal numbers in the range of upper
and lower limits as given in screenshots.

Use of while loop, if else, for loop, nested loops is allowed. Functions, arrays and goto statements are NOT allowed.

24
011000
30
18
25
011001
31
19
26
011010
32
la
27
011011
33
lb
le
1d
28
011100
34
29
011101
35
30
011110
36
le
31
011111
37
If
32
100000
40
20
Transcribed Image Text:24 011000 30 18 25 011001 31 19 26 011010 32 la 27 011011 33 lb le 1d 28 011100 34 29 011101 35 30 011110 36 le 31 011111 37 If 32 100000 40 20
Example output:
Please enter one of a number from this list (256, 128, 64, 32, 16, 8, 4 or 2) as upper limit: 45
You should enter the upper limit from this list only: 256, 128, 64, 32, 16, 8, 4, 2
Please enter the upper limit: 32
Enter lower limit: -12
You should enter the value greater than 0 and less than the upper limit
Enter lower limit: 50
You should enter the value greater than 0 and less than the upper limit
Enter lower limit: 10
Decimal
Binary
Octal
Hexadecimal
10
001010
12
a
11
001011
13
b
12
001100
14
13
001101
15
d
14
001110
16
15
001111
17
f
16
010000
20
10
17
010001
21
11
18
010010
22
12
19
010011
23
13
20
21
010100
24
14
25
26
010101
15
22
010110
16
23
010111
27
17
Transcribed Image Text:Example output: Please enter one of a number from this list (256, 128, 64, 32, 16, 8, 4 or 2) as upper limit: 45 You should enter the upper limit from this list only: 256, 128, 64, 32, 16, 8, 4, 2 Please enter the upper limit: 32 Enter lower limit: -12 You should enter the value greater than 0 and less than the upper limit Enter lower limit: 50 You should enter the value greater than 0 and less than the upper limit Enter lower limit: 10 Decimal Binary Octal Hexadecimal 10 001010 12 a 11 001011 13 b 12 001100 14 13 001101 15 d 14 001110 16 15 001111 17 f 16 010000 20 10 17 010001 21 11 18 010010 22 12 19 010011 23 13 20 21 010100 24 14 25 26 010101 15 22 010110 16 23 010111 27 17
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education