Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Implement and test the following functionalities through C code fragments. a) Write a C code fragment to check a bit value. Declare three

 

1. Implement and test the following functionalities through C code fragments. a) Write a C code fragment to check a bit value. Declare three character type variables ch1, ch2 and mask with initial values of 0x34 and 0x20 for chl and mask, respectively. C code should set character type variable ch2 to 1 if the bit 5 in mask is 1, otherwise 0. Note that bits in a byte are numbered from 0 (lsb) to 7 (msb). b) Write a C code fragment to set a bit value. Declare two character type variables chl and mask with initial value of 0x34 for ch1. C code should set bit 7 in variable ch1 to 1 using mask without changing any other bit values in chl. c) Write a C code fragment to clear a bit value. Declare two character type variables chl and mask with initial value of 0x34 for ch1. C code should clear bit 3 in variable ch1 to 0 using mask without changing any other bit values in chl. d) Write a C code fragment to toggle a bit value. Declare two character type variables ch1 and mask with initial value of 0x34 for ch1. C code should toggle bit 4 in variable chl using mask without changing any other bit values in chl.

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_2

Step: 3

blur-text-image_3

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Computer Network questions

Question

If 2 5 9 - k 5 8 = 2 5 8 , what is the value of k?

Answered: 1 week ago