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
reminder it an exercice not a grading work             GETTING STARTED Open the file SC_EX19_EOM2-1_FirstLastNamexlsx, available for download from the SAM website. Save the file as SC_EX19_EOM2-1_FirstLastNamexlsx by changing the “1” to a “2”. If you do not see the .xlsx file extension in the Save As dialog box, do not type it. The program will add the file extension for you automatically. With the file SC_EX19_EOM2-1_FirstLastNamexlsx still open, ensure that your first and last name is displayed in cell B6 of the Documentation sheet. If cell B6 does not display your name, delete the file and download a new copy from the SAM website. Brad Kauffman is the senior director of projects for Rivera Engineering in Miami, Florida. The company performs engineering projects for public utilities and energy companies. Brad has started to create an Excel workbook to track estimated and actual hours and billing amounts for each project. He asks you to format the workbook to make the…
Need help completing this algorithm here in coding! 2
Whats wrong the pseudocode here??
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