Question: To get input from the user, enter these commandlTo get input from the user, enter these commandline arguments: four characters ( any ASCII character )

To get input from the user, enter these commandlTo get input from the user, enter these commandline arguments: four characters (any ASCII character) followed by two integers.Otherwise, print error message and end program.
To convert a string to an integer, use the function atoi(). For example:int integer1= atoi(argv[5]);
Use data types "unsigned int" and "unsigned char". Be careful with looping, as there will be no negative integers.
Function #1: This function calculates the two's complement. The function's parameter is one unsigned integer (unsigned int). The function returns a signed integer (int), which is the two's complement of the parameter. Use the one's complement operator (~) to get the one's complement. Add one (1) to the to the one's complement to get the two's complement.
Function #2: This function packs four characters into one integer. The function's parameters are four unsigned characters. The function returns an unsigned integer. Use the left shift operator (<<) and the bitwise inclusive OR operator (|) to pack four 8-bit characters into a 32-bit integer.
Function #3: This function unpacks an integer into four characters. The function's parameters are an unsigned integer (which is input to the function), and four character pointers (which are the outputs of the function). This function does not return anything. Use the right-shift operator (>>) and the bitwise AND operator (&) with a mask to separate the 32-bit integer into four 8-bit parts, and store these four 8-bit parts in the four 8-bit characters. In other words, take one 32-bit integer (int) and convert it into four 8-bit characters (char).
***** Here is an example function prototype:
void unpackCharacters(unsigned int, unsigned char*, unsigned char*, unsigned char*, unsigned char*);
Function #4: This function is a circular left shift of the bits. The function's parameter are two unsigned integers: integer1 and integer2. The function returns an unsigned integer. This function will return an unsigned integer with integer2's bits rotated to the left integer1's number of times. You may need to use a mask, left shift operator (<<), right shift operator (>>), the bitwise AND operator (&), and the bitwise inclusive OR operator (|).
*****
In other words, when the bits are shifted to the left by one, the bit in the leftmost position will be moved to the rightmost position. When the bits are shifted to the left by 2, the 2 bits in the leftmost position will be moved to the rightmost position. Etc.
*****
One possible solution is for the circular left shift operation is:
circularLeftShift(n, x)=(x << n) OR (x >>32-n)
Replace the "OR" with the inclusive or operator (|)
Here is an outline of the program with the four function prototypes described in the instructions:LastnameFirstname16.c
Your output should match the output below. You can use the printbits() function in your code; however, you also need to create your own function that displays the eight bits in a character.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!