Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 of 2 Q 01homework homework1.pdf 140.53% V R = 00 | Thu... * * CSCE 240 HOMEWORK 1 DUE: 04 FEB 2020 You shall

image text in transcribedimage text in transcribed

1 of 2 Q 01homework homework1.pdf 140.53% V R = 00 | Thu... * * CSCE 240 HOMEWORK 1 DUE: 04 FEB 2020 You shall submit a zipped, and only zipped, archive of your homework directory, hwl. The directory shall contain, at a minimum, the file binary-converter.cc. Your submission file must be named hwl.zip. I will use my own makefile to make your binary-converter.cc file. Do not use a header for this assignment. My grader will not look for one. Everyone in computing should have a basic understanding of binary integers. To that end, you will write an app to convert decimal to binary. The application should perform as follows: The program is called and runs with no prompt for input. The first value provided to the standard input stream shall be an integer and be interpreted as the number of bits of binary output. This value should be something in the range [1, 31]. Do be careful, sometimes I get careless and enter values outside this range. If that happens, the app should quietly exit with a value of 1. The second value provided is the decimal integer to be converted. Though I can guarantee that you will see values in the range [0, 201 1], I am sometimes careless about the number of bits required to represent a decimal integer. If I make a mistake by entering a value too large for the number of bits, that is on me and you should still only print the number of bits requested. If I enter a negative value, do not print a two's complement; again, quietly exit, this time with a value of 2. An algorithm to convert decimal number, n, to binary (without arrays): 1. Use loop to calculate the largest power of 2, call it i, in n, print a 1 and subtract 2 from n.1 1 of 2 Q 01homework homework1.pdf 140.53% v R = | Thu... * * An algorithm to convert decimal number, n, to binary (without arrays): 1. Use loop to calculate the largest power of 2, call it i, in n, print a 1 and subtract 21 from n.1 2. For each exponent, j, from i 1 down to 0, (a) if that 2i <>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions