1. Implement and test the following functionalities through C code fragments. a) Write a C code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these computer network questions
-
Revenue from Contracts with Customers -- was issued in September 2015 and applies to accounting periods beginning on or after 1 January 2018. IFRS 15 replaces IAS 11- Construction Contracts - and IAS...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Tri-State Railroad Company organizes its three divisions, the Southeast (SE), East (E), and South (S) regions, as profit centers. The chief executive officer (CEO) evaluates divisional performance,...
-
A neutral pion (mass 0.135 GeV/c2) decays via the electromagnetic interaction into two photons: 0 + . What is the energy of each photon, assuming the pion was at rest?
-
A balloon at sea level contains 2 kg of helium at 30 C and 1 atm. The balloon then rises to 1500m above sea level. At this height, the helium temperature is 6 C. Determine the change in internal...
-
Plaintiffs W. O. and J. C. Lucy had wanted to purchase Ferguson Farm from the Zehmers for at least eight years. One night, Lucy stopped by the establishment the Zehmers operated and said that he bet...
-
Refer to the financial statements and the Notes to Consolidated Financial Statements of Tootsie Roll Industries in Appendix A. Instructions Answer the following questions. (a) What were the total...
-
Make a Relational Model Table and Define Keys from Entity Relation Diagram Q2: Design the World Music Association Database using given ERD. ORCHESTRA "Orchestra Name City Country Music Director...
-
The following pairs of soluble solutions can be mixed. In some cases, this leads to the formation of an insoluble precipitate. Decide, in each case, whether or not an insoluble precipitate is formed....
-
Now that we know F2 and F3, we can find the net force on particle q by adding these two forces together. F = -14.4 N F3 = 2.28 N F= [?]N Be sure to include the direction of the force a minus sign if...
-
Classify each action based on whether it increases or decreases the activity of glycogen synthase. Increases glycogen synthase activity glucose binding to glycogen phosphorylase binding of cyclic AMP...
-
Look carefully at the four speed-time graphs above. Determine which graph represents the motion of the 5 g ball from the moment the astronaut starts blowing (t = 0).
-
A 90 reducer elbow deflects water downwards into a smaller diameter pipe. Calculate the mass flow rate, the exit velocity and the resultant force exerted on the reducer by water. Water density is...
-
The bones of the forearm (radius and ulna) are hinged to the humerus at the elbow. The biceps muscle connects to the bones of the forearm about 2.15 cm beyond the joint. Assume the forearm has a mass...
-
1. Prepare a table-based ABC analysis of usage value. Classify as follows: A-items: top 20% of usage value B-items: next 30% of usage value C-items: remaining 50% of usage value 2. Calculate the...
-
Give codons for the following amino acids: (a) Th (b) Asp (c) Thr
-
(a) Show for a 2D Hall bar of length \(L\) and width \(w\) that \(j=\sigma E\) (where \(j\) is the current density, \(E\) is the electric field, and \(\sigma\) is the conductivity) is equivalent to...
-
A European charity has an asset allocation at the beginning of the year consisting of the asset classes and weights shown in Exhibit 11. As Exhibit 11 reveals, the charity has a policy that the asset...
-
Wakuluk is most likely to make significant adjustments to her estimate of the future growth trend for which of the following countries? A. Country Y only B. Country Z only C. Countries Y and Z Neshie...
Study smarter with the SolutionInn App