Question: I need this in C using linux your program should print out either byte order: big-endian or byte order: small-endian depending on the characteristics of
I need this in C using linux your program should print out either byte order: big-endian or byte order: small-endian depending on the characteristics of the machine your code is running on. Your program should figure this out at run time, not at compile time.
Then your code should repeatedly prompt for input by printing "-->", and then accept user input via scanf() in the form of 4 hexadecimal digits. Your code will interpret this input as a 16-bit unsigned short. For each input item, your code should extract bits 6 through 9 and print out the unsigned numerical value of those bits. When the user enters 0, your code should print "done" and exit.
For example, if the user inputs AABB, your code should print out 10.
Sample output:
classname - Assignment 1 - Student Name byte order: small-endian --> 1234 8 --> abcd 15 --> 0 done Meets+ Additional Task
Flip the bits of the extracted bits 6 through 9, replace bits 6 through 9 in the original value with the flipped bits, and print the modified input value. "Flip the bits" means change all 1's to 0's, and all 0's to 1's.
For example, if the user inputs ABCD, your code should extract bits 6 through 9, flip those bits, insert the flipped bits into the original value, and print out 0xA80D.
Sample output:
CS 201 - Assignment 1 - Student Name byte order: small-endian --> 1234 8 0x11F4 --> abcd 15 0xA80D --> ffff 15 0xFC3F --> 0 done
{the code should accept hex value and transform it to numerical as the sample shows }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
