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...
-
E11.7 (LO 2. 3), AP Levine Inc., which produces a single product, has prepared the following standard cost sheet for one unit of the product. Direct materials (8 pounds at $2.50 per pound) Direct...
-
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 proton in Fermilab's Tevatron is accelerated through a potential difference of 2.5 MV during each revolution around the ring of radius 1.0 km. In order to reach an energy of 1 TeV, how many...
-
what concepts and differences of opinions for defining circular economies. See section two in the attached reading to get started. Mika Sillanp, & Chaker Ncibi. (2019). The circular economy: Case...
-
On January 1, 2020, Lazer Inc. purchased for cash, ten \(\$ 1,000,4 \%\) bonds of Star Corp. at par. The bond interest is paid annually on January 1 of each year, and the bond maturity date is...
-
(Entries and Questions for Bond Transactions) On June 30, 2010, Mackes Company issued $5,000,000 face value of 13%, 20-year bonds at $5,376,150, a yield of 12%. Mackes uses the effective-interest...
-
An eight-month European put option on a dividend-paying stock is currently selling for $5. The stock price is $33, the strike price is $35, and the risk-free interest rate is 9% per annum. The stock...
-
The adjusted trial balance for Burlington Advertising Services is presented below: (Click on the icon to view the adjusted trial balance.) Read the requirements Requirement 1. Prepare the income...
-
4. ApCo uses the perpetual method and FIFO. Here are its 20X9 inventory records as of Dec . 31 : Units Unit cost Total cost January Beginning 800 $50.00 $40,000 inventory March 12 Purchase 1,000...
-
Describe how boundary layer theory is used to analyze momentum and heat transfer in complex fluid flow systems. What are the key factors that influence the thickness and behavior of boundary layers...
-
1. A company purchases feed supplements for their pigs from Round Up Feed in the amount of $1,000 on account. 1. What is the initial journal entry for this transaction? 2. NET 30: What will be the...
-
Discuss four important issues that will shape compensation professionals work for years to come. Explain in details.
-
If its initial velocity is 1.0 m/s, at what time is its displacement 5.0 m? If its initial velocity is 1.0 m/s, at what time is its displacement 5.0 m?
-
How do motivational theories such as expectancy theory and goal-setting theory apply to employee performance and behavior in the workplace ?
-
Sheffield Accounting performs two types of services, Audit and Tax. Sheffield's overhead costs consist of computer support, $246000; and legal support, $117000. Information on the two services is:...
-
If 2 5 9 - k 5 8 = 2 5 8 , what is the value of k?
-
Cedar Corporation has an S corporation election in effect. During the 2012 calendar tax year, the corporation had ordinary taxable income of $200,000, and on January 15, 2012, the corporation paid...
-
During the 2012 tax year, Irma incurred the following expenses: Union dues..............................................................$275 Tax return preparation...
-
Ray and Maria Gomez have been married 3 years. They live at 1610 Quince Ave., McAllen, TX 78701. Ray works for Palm Oil Corporation and Maria works for the City of McAllen. Maria's Social Security...
-
\(\frac{3}{14}+\frac{8}{21}\) Perform the indicated operations. Reduce to lowest terms.
-
\(\frac{13}{24}-\frac{4}{117}\) Perform the indicated operations. Reduce to lowest terms.
-
\(\frac{14}{27} \div \frac{7}{12}\) Perform the indicated operations. Reduce to lowest terms.
Study smarter with the SolutionInn App