Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
bartleby

Videos

Textbook Question
Book Icon
Chapter 11, Problem 6E

Write a function called b that looks for the occurrence of a specified pattern of bits inside an u . The function should take three arguments and should be called as shown:

b

The function searches the integer s , starting at the leftmost bit, to see if the rightmost n bits of p occur in s , If the pattern is found, have the function return the number of the bit at which the pattern begins, where the leftmost bit is bit number 0. If the pattern is not found, then have the function return -1. So, for example, the call

i

causes the b function to search the number 0xelf4( = 1110 0001 1111 0100 binary) for the occurrence of the three-bit pattern 0x5 (= 101 binary). The function returns 1 to indicate that the pattern was found in the source beginning with bit number 1 .

Make certain that the function makes no assumptions about the size of an i (see exercise 3 in this chapter).

Blurred answer
Students have asked these similar questions
Q2} Write a user-define function that add or subtracts two polynomials of any order. Use the function to add and subtract the following f₁(x)=x5-7x4+11x³-4x²-5x-2 and f₂(x)=9x²-10x+6 polynomials:
Write a function int Factorial(int n) to calculate factorial of n. If n is non negative then it return factorial, otherwise it display a proper error message and return -1.
Write a function that returns the greatest common divisor of 2 integers.

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY