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
Start by writing a function, plot_grades (filename, first_name, last_name), which plots the grades for the specified student. This will be very similar in nature to what you did in Assignment 5.2 but will use the csv library instead of split (). a. The function should find the specified student in the file associated with filename. b. It should use plotter to plot all of the graded items for that student. c. Manually test your function using the full grades_ XXX.csv files.
Let A and B two text files, containing some binary lines between of length 1...N. Where N is the line with the maximum number of characters, 1 the minimum number of characters in each line. Design a Python3 function to compare each line of the files, character by character, and if there is a match of the characters, create a variable representing the similarity between the lines of each file, and return that similarity variable measures the similarity between two files.
Write a recursive function, displayFiles, that expects a pathname as an argument. The path name can be either the name of a file or the name of a directory. If the pathname refers to a file, its filepath is displayed, followed by its contents, like so: File name: file_path Lorem ipsum dolor sit amet, consectetur adipiscing elit... Otherwise, if the pathname refers to a directory, the function is applied to each name in the directory, like so: Directory name: directory_path File name: file_path1 Lorem ipsum dolor sit amet... File name: file_path2 Lorem ipsum dolor sit amet... ...
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