Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

5. What information would the team members need?

Answered: 1 week ago