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:
Please explain your solution
A company wants to transmit data over the telephone but is concerned that its phones may b tapped. It has asked you to write a program that will encrypt the data so that it may be transmitted more securely. All the data transmitted is 4 digit integers. Your program should read a four digit integer entered by the user and calls a function encrypt which takes four digits as arguments and encrypt it as follows . Replace each digit with the result of adding 4 to the digit and getting the remainder after dividing the new value by 10. . Calls another function swap which swaps the first digit with the third, and second digit with the fourth using pass by reference. Then it prints the encrypted integer.

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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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