1) Write a function which counts the number of set bits (1) inside the second byte...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1) Write a function which counts the number of set bits (1) inside the second byte from right of an integer. Example: - Integer: 346453838 - Binary: 00010100 10100110 01110111 01001110 Answer: 6 2) Write a function which detects whether the sequence "110" appears inside the second byte from right of an integer. Example: - Integer: 346453838 Binary: 00010100 10100110 01110111 01001110 Answer: Yes Integer: 5788886 - Binary: 00000000 01011000 01010100 11010110 Answer: No You can use the following function to print the bits of an integer. #include void print_bits(int number) { int i, count=0; for(i=31; i>=0; i--) { if (number & 1 < < i) { printf("1"); } else { printf("0"); } count++; if ((count>>3) < <3 == count) { printf(" ");} 1) Write a function which counts the number of set bits (1) inside the second byte from right of an integer. Example: - Integer: 346453838 - Binary: 00010100 10100110 01110111 01001110 Answer: 6 2) Write a function which detects whether the sequence "110" appears inside the second byte from right of an integer. Example: - Integer: 346453838 Binary: 00010100 10100110 01110111 01001110 Answer: Yes Integer: 5788886 - Binary: 00000000 01011000 01010100 11010110 Answer: No You can use the following function to print the bits of an integer. #include void print_bits(int number) { int i, count=0; for(i=31; i>=0; i--) { if (number & 1 < < i) { printf("1"); } else { printf("0"); } count++; if ((count>>3) < <3 == count) { printf(" ");}
Expert Answer:
Related Book For
Statistics for Business Decision Making and Analysis
ISBN: 978-0321890269
2nd edition
Authors: Robert Stine, Dean Foster
Posted Date:
Students also viewed these programming questions
-
In the United States, taxpayers in the top 1 percent of the income distribution pay about percent of their income in federal taxes. a. 5 b. 10 c. 20 d. 30
-
rn Write a C program that counts the number of each digit entered by the user (Input process should be ended using EOF character). You should use switch to compute the number of each digits. For each...
-
The table shown with this question counts the number of calls that arrive at a telephone help desk during the hours of 1 to 3 P.M. on 5 weekdays. The company uses the same number of employees to...
-
If Jody's records show $2,000 in investment by owner, $10,000 in net income, $5,000 in assets and $1,000 in owner's drawings. What is Jody's ending owner's equity on a statement of changes in owner's...
-
What four main types of actions involve databases? Briefly discuss each.
-
A factory machine was purchased for $375,000 on January 1, 2014. It was estimated that it would have a $75,000 salvage value at the end of its 5-year useful life. It was also estimated that the...
-
1. To develop an understanding of your ethical leadership style 2. To understand how your preferred ethical leadership style relates to other ethical leadership styles Directions 1. Please read the...
-
The Art League is a not-for-profit organization dedicated to promoting the arts within the community. There are two programs conducted by the Art League: (1) exhibition and sales of members art...
-
Recent events have once again shaken and stirred the memory of the nation. Almost immediately after the Civil War, a myth arose painting the conflict with a brush that attempted to blur the lines...
-
A multi-loop block diagram is shown in Figure E3.9.The state variables are denoted by x1 and x2. (a) Determine a state variable representation of the closed-loop system where the output is denoted by...
-
For the second order instrument in problem 4, find M(m) and o (m) for the components of the input signal F(t) =4 sin(2m(0.223)t) sin(27(1)t) + 0.5 sin(2a(1.87)t). What is the resonance frequency of...
-
During Module 6, you read about, heard lectures about, and thought about the relationship between employers and their employees. How should employers treat their employees? And vice versa. What do...
-
You are given the following information for ABB Company. As of year 1, the company's book value is RM80,000 and its cost of capital is 15%. Year 1 Year 2 Sales Year 5 RM135,000 RM130,000 RM130,000...
-
16. Read each brief description of a project in the following table and classify its type according to the Obeng model (Fog, Quest, Movie, Paint by Numbers (PBN)). (5) Project Reduce the cost of...
-
Compass Minerals Inc. has a complex capital structure with many dilutive preferred share series and call options that are in-the-money. When there are multiple dilutive securities in a firm, the test...
-
The following information pertains to the next two questions. Fordlane Co . purchased inventory that cost $ 1 0 , 0 0 0 under terms 2 / 1 0 , n / 3 0 . The inventory was delivered under terms FOB...
-
Develop a Table showing Descriptions of Actors and Use Cases: Actor Description Student A person enrolled in courses. Faculty Teaching staff responsible for courses. Administrator System...
-
Research corporate acquisitions using Web resources and then answer the following questions: Why do firms purchase other corporations? Do firms pay too much for the acquired corporation? Why do so...
-
The US Census tracks the number of women-owned businesses that have a payroll. In 1992, women owned more than 800,000 such firms in the United States. The data identify the industry for all but 9,000...
-
Historically a bank expects about 5% of its borrowers to default (not repay). The bank currently has 250 loans outstanding. (a) In order to use a binomial model to compute the probabilities...
-
This data table gives annual costs of 223 commercial leases. All of these leases provide office space in a Midwestern city in the United States. For the response, use the cost of the lease (in...
-
Based on the photographs in Figure 26.13, in which segment(s) is the Antp gene normally expressed? Figure 26.13: (a) Normal fly (b) Antennapedia mutant
-
The bush baby, a small African mammal, is a remarkable jumper. Although only about 8 inches long, it can jump, from a standing start, straight up to a height of over 7 feet! Use the particle model to...
-
Hicham El Guerrouj of Morocco holds the world record in the 1500 m running race. He ran the final 400 m in a time of 51.9 s. What was his average speed in mph over the last 400 m? A. 14.2 mph B. 15.5...
Study smarter with the SolutionInn App