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

Concept explainers

Question
Book Icon
Chapter 11, Problem 8E
Program Plan Intro

Program Plan:

  • Include the necessary header files into program.
  • Define the function named “bitSize()” which is used to fetch the size of the value.
    • Declare the variables in type of unsigned int and int.
    • Using “while” loop, check the value of “size”.
      • If the value greater than “0”, right shift operation is performed and increments the “temp” value.
    • Return the value of “temp-1”.
  • Define the function named “no_of_bits()” which is used to calculate the minimum number of bits needed to represent the value.
    • Declare and initialize the variables.
    • Using “while” loop, check the value and left shift the value of “temp” and increment the “counter” value.
    • Return the size which is reduced from counter.
  • Define the function named “bitpat_get()” which is used to extract the “n” bits from source starting at “start” argument.
    • Declare the variables.
    • Call the “bitSize()” method and store the size into variable “size”.
    • Initialize the value of “c” in type of integer.
    • Using “if…else” condition, calculate the offset and temporary value.
    • Return the temporary value to function.
  • Define the function named “bitpat_set()” which is used to set the bit size within the source to value which is starting at “*start”.
    • Declare the variables.
    • Call the “no_of_bits()” method which passes “*start” as argument.
    • Call the other appropriate methods and store in the variable.
    • Using left shift operator to calculate the value of “val”.
    • Print the appropriate result on screen.
  • Define the main method.
    • Declare the variables in type of unsigned integer.
    • Prompt and get the values.
    • Call the “bitpat_set()” method and print the result on screen.

Blurred answer
Students have asked these similar questions
I would like to know the main features about the following three concepts: 1. Default forwarded 2. WINS Server 3. IP Security (IPSec).
map the following ER diagram into a relational database schema diagram. you should take into account all the constraints in the ER diagram. Underline the primary key of each relation, and show each foreign key as a directed arrow from the referencing attributes (s) to the referenced relation.   NOTE: Need relational database schema diagram
What is business intelligence? Share the Business intelligence (BI) tools you have used and explain what types of decisions you made.
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++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT