Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program called convert that reads a signed decimal integer from the user and prints the number in 4 different ways: signed decimal,

Write a C program called "convert" that reads a signed decimal integer from the user and prints the number in 4 different ways: signed decimal, unsigned decimal, hexadecimal, and binary. 
Here are a few example runs of the program: 
 $ ./convert -1 signed dec: -1 unsigned dec: 4294967295 

hex: binary:

ffffffff 1111 1111 1111 1111 1111 1111 1111 1111 
$ ./convert 256 signed dec: unsigned dec: 256 hex: 100 binary: 0000 0000 0000 0000 0000 0001 0000 0000 

256

There is a bash shell trick that you might find useful for testing your program. You can evaluate an arithmetic expression like this: 
 $ echo $(( 1 + 2 + 3 )) 6 
In addition, you can take the output of one program, and feed it as a user input to another program by chaining the two programs with | character. So, you can input the minimum 32-bit integer like this: 
 $ echo $(( -2 * 1024 * 1024 * 1024 )) | ./convert signed dec: -2147483648 unsigned dec: 2147483648 hex: 80000000 
 binary: 1000 0000 0000 0000 0000 0000 0000 0000 
Note that your program must behave EXACTLY the same as the sample runs shown above. Given the same number, your program must generate the EXACT same output--same order, same strings, same spacing. 

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

how would you have done things differently?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago