A decimal number 'n' between 0 and 31 can be expressed in binary system as a4a3a2ala0, where ai's are either zero or one (i.e. n = a4 * 24 + a3 * 2 3 + a2 * 22 + a1 * 2'+ ao * 2 º ). Write a C program that accepts a decimal number 'n' in the above range and prints the equivalent binary representation. Test data and expected output: Enter a +ve no less than 32: -5, O/P - Entered number is out of range Enter a +ve no less than 32: 21, O/P- Binary equivalent of decimal number 21 is 10101 Enter a +ve no less than 32: 14, O/P- 14 Binary equivalent of decimal number 14 is 1110 Enter a +ve no less than 32: 35, O/P - Entered number is out of range

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

A decimal number 'n' between 0 and 31 can be expressed in binary system as
a4a3a2ala0, where ai's are either zero or one
(i.e. n = a4 * 24 + a3 * 2 + a2 * 22 + a1
Write a C program that accepts a decimal number 'n' in the above range and
prints the equivalent binary representation.
* 2'+ ao * 2° ).
3
Test data and expected output:
Enter a +ve no less than 32: -5, O/P - Entered number is out of range
Enter a +ve no less than 32: 21, O/P- Binary equivalent of decimal number 21 is
10101
Enter a +ve no less than 32: 14, O/P- 14 Binary equivalent of decimal number
14 is 1110
Enter a +ve no less than 32: 35, O/P - Entered number is out of range
Transcribed Image Text:A decimal number 'n' between 0 and 31 can be expressed in binary system as a4a3a2ala0, where ai's are either zero or one (i.e. n = a4 * 24 + a3 * 2 + a2 * 22 + a1 Write a C program that accepts a decimal number 'n' in the above range and prints the equivalent binary representation. * 2'+ ao * 2° ). 3 Test data and expected output: Enter a +ve no less than 32: -5, O/P - Entered number is out of range Enter a +ve no less than 32: 21, O/P- Binary equivalent of decimal number 21 is 10101 Enter a +ve no less than 32: 14, O/P- 14 Binary equivalent of decimal number 14 is 1110 Enter a +ve no less than 32: 35, O/P - Entered number is out of range
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY