Enter the first character :K Enter the second character :L Enter the third character :M Enter the forth character :N Result before shifting and_replacinglast 8 bits with K O -00000000 00000000 00000000 0000000 Result after shifting and_replacing last 8 bits with K 75 =0000000 00000000 00000000 01001011 Result before shifting and_replacing last 8 bits with L 75 -00000000 00000000 00000000 01001011 Result after_shifting and_replacing last 8 bits with L 19276 -00000000 000000ød 0100i011 01001100 Result before shifting and_replacing last 8 bits with M 19276 -00000000 00000000 01001011 01001100 Result after shifting and replacing last 8 bits with M 4934733 -0000000 01001011 0100i100 01001101 Result before shifting and replacing last 8 bits with N 4934733 =0000000 B1001011 01001180 01001101 Result after shifting and replacing 1last 8 bits with N 1263291726 =01001011 01001100 01001101 8100111i0 Page 4 of 5 Tips: Implement the user input logic last. Hard code the variable(s) with the respective values K",'L','M', and 'N', and get everything else to work first. To display the binary representation of the integer, use the conversion logic provided in the text book or any other source. Do credit the source in your code. 10.12 (Packing Characters into an Integer) The left-shift operator can be used to pack four char- acter values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an un- signed int variable, assign the first character to the unsigned int variable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator. Repeat this process for the third and fourth characters. The pro- gram should output the characters in their bit format before and after they're packed into the un- signed int to prove that the characters are in fact packed correctly in the unsigned int variable. Do not use global variables. If your scanf is not waiting for your input, it is because it consumed the Carriage Return from the buffer remained from the previous scanf. This only happens if you use %c in the scanf. To remove left over Carriage Return in the buffer, use getchar(); right after the scanf("%c"). Refer to slides that covered user input and how to clear buffer for further explanation. Information about packCharacter function Should accept one character and the target integer that will be used for packing. Should perform the left shift and append the character to the target. Should not include user input Should not include output. Expected input and output.

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

using chapters 1 to 10 from the book C how to program edition 8

Enter the first character :K
Enter the second character :L
Enter the third character :M
Enter the forth character :N
Result before shifting and_replacinglast 8 bits with K
O -00000000 00000000 00000000 0000000
Result after shifting and_replacing last 8 bits with K
75 =0000000 00000000 00000000 01001011
Result before shifting and_replacing last 8 bits with L
75 -00000000 00000000 00000000 01001011
Result after_shifting and_replacing last 8 bits with L
19276 -00000000 000000ød 0100i011 01001100
Result before shifting and_replacing last 8 bits with M
19276 -00000000 00000000 01001011 01001100
Result after shifting and replacing last 8 bits with M
4934733 -0000000 01001011 0100i100 01001101
Result before shifting and replacing last 8 bits with N
4934733 =0000000 B1001011 01001180 01001101
Result after shifting and replacing 1last 8 bits with N
1263291726 =01001011 01001100 01001101 8100111i0
Page 4 of 5
Tips:
Implement the user input logic last. Hard code the variable(s) with the respective values K",'L','M', and
'N', and get everything else to work first.
To display the binary representation of the integer, use the conversion logic provided in the text book or
any other source. Do credit the source in your code.
Transcribed Image Text:Enter the first character :K Enter the second character :L Enter the third character :M Enter the forth character :N Result before shifting and_replacinglast 8 bits with K O -00000000 00000000 00000000 0000000 Result after shifting and_replacing last 8 bits with K 75 =0000000 00000000 00000000 01001011 Result before shifting and_replacing last 8 bits with L 75 -00000000 00000000 00000000 01001011 Result after_shifting and_replacing last 8 bits with L 19276 -00000000 000000ød 0100i011 01001100 Result before shifting and_replacing last 8 bits with M 19276 -00000000 00000000 01001011 01001100 Result after shifting and replacing last 8 bits with M 4934733 -0000000 01001011 0100i100 01001101 Result before shifting and replacing last 8 bits with N 4934733 =0000000 B1001011 01001180 01001101 Result after shifting and replacing 1last 8 bits with N 1263291726 =01001011 01001100 01001101 8100111i0 Page 4 of 5 Tips: Implement the user input logic last. Hard code the variable(s) with the respective values K",'L','M', and 'N', and get everything else to work first. To display the binary representation of the integer, use the conversion logic provided in the text book or any other source. Do credit the source in your code.
10.12 (Packing Characters into an Integer) The left-shift operator can be used to pack four char-
acter values into a four-byte unsigned int variable. Write a program that inputs four characters from
the keyboard and passes them to function packCharacters. To pack four characters into an un-
signed int variable, assign the first character to the unsigned int variable, shift the unsigned int
variable left by 8 bit positions and combine the unsigned variable with the second character using
the bitwise inclusive OR operator. Repeat this process for the third and fourth characters. The pro-
gram should output the characters in their bit format before and after they're packed into the un-
signed int to prove that the characters are in fact packed correctly in the unsigned int variable.
Do not use global variables. If your scanf is not waiting for your input, it is because it consumed the Carriage
Return from the buffer remained from the previous scanf. This only happens if you use %c in the scanf. To remove
left over Carriage Return in the buffer, use getchar(); right after the scanf("%c"). Refer to slides that covered user
input and how to clear buffer for further explanation.
Information about packCharacter function
Should accept one character and the target integer that will be used for packing.
Should perform the left shift and append the character to the target.
Should not include user input
Should not include output.
Expected input and output.
Transcribed Image Text:10.12 (Packing Characters into an Integer) The left-shift operator can be used to pack four char- acter values into a four-byte unsigned int variable. Write a program that inputs four characters from the keyboard and passes them to function packCharacters. To pack four characters into an un- signed int variable, assign the first character to the unsigned int variable, shift the unsigned int variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator. Repeat this process for the third and fourth characters. The pro- gram should output the characters in their bit format before and after they're packed into the un- signed int to prove that the characters are in fact packed correctly in the unsigned int variable. Do not use global variables. If your scanf is not waiting for your input, it is because it consumed the Carriage Return from the buffer remained from the previous scanf. This only happens if you use %c in the scanf. To remove left over Carriage Return in the buffer, use getchar(); right after the scanf("%c"). Refer to slides that covered user input and how to clear buffer for further explanation. Information about packCharacter function Should accept one character and the target integer that will be used for packing. Should perform the left shift and append the character to the target. Should not include user input Should not include output. Expected input and output.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 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