Question
The left-shift operator can be used to pack two character values into a 2-byte unsigned int variable. Write a program that inputs two characters from
The left-shift operator can be used to pack two character values into a 2-byte unsigned int variable. Write a program that inputs two characters from the keyboard and passes them to function packCharacters. To pack two characters into an unsigned 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. The program should output the characters in their bit format before and after theyre packed into the unsigned int to prove that the characters are in fact packed correctly in the unsigned int variable.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started