Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a C program called check_even.c that checks if a given integer is even or odd. This program should prompt (ask) its user to
1. Write a C program called check_even.c that checks if a given integer is even or odd. This program should prompt (ask) its user to provide a value between 0 and 255. Then, it would store this value as an 8-bit unsigned integer, check if it is even or odd, and print the corresponding message on the screen (e.g., The number is odd"). If the user inputs a value that is wider than 8 bits (larger than 256), the program should consider only the least significant 8 bits and discard the rest. What happens when the user provides a negative value? 2. Solve a puzzle. Consider the following C program, with two variable values redacted. Note that the short int type is 16 bits (2 bytes) wide, and the output statements all use (unsigned) decimal, not hex. #include int main() { unsigned short int s = /* ??? */; unsigned short int t = /* ??? */; printf("s >> 8 = %u ", s 8 ); printf("s & xff = %u ", s & 0xff ); printf("s ^t = %u ", s ^ t ); return 0; } Given (below) the output of this program, can you deduce the values of the variables s and t? You may have to convert the unsigned integer values to hexadecimal or binary. s >> 8 = 128 s & 0xff = 15 s ^ t = 36863
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