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
This problem needs to be solved in python. Write a function read_movies_data(f) that takes in a movies file and returns a pandas DataFrame, where the index is the movie id and the columns are "title", "year", and "genre" (in that order). movies_df = read_movies_data("moviesSample.txt")   assert movies_df.shape == (9, 3)assert movies_df.iloc[2, 2] == "Comedy"assert movies_df.loc[6, "title"] == "Heat"assert all(movies_df.columns == ["title", "year", "genre"])assert list(movies_df.index) == [1, 2, 3, 4, 5, 6, 8, 9, 10]   NOTE: Make sure all of the asserts work   The moviesSample.txt looks like this: 1|Toy Story|1995|Adventure2|Jumanji|1995|Adventure8|Tom and Huck|1995|Adventure3|Grumpier Old Men|1995|Comedy4|Waiting to Exhale|1995|Comedy5|Father of the Bride Part II|1995|Comedy6|Heat|1995|Action9|Sudden Death|1995|Action10|GoldenEye|1995|Action   NOTE: Try to sent screenshots of the code working.
PROGRAM IN PLAIN C PLEASE! Write a void function that will merge the contents of two text files containing chemical elements sorted by atomic number and will produce a sorted file of binary records. The function’s parameters will be three file pointers. Each text file line will contain an integer atomic number followed by the element name, chemical symbol, and atomic weight. Here are two sample lines: 11 Sodium Na 22.99 20 Calcium Ca 40.08 The function can assume that one file does not have two copies of the same element and that the binary output file should have this same property. Hint: When one of the input files is exhausted, do not forget to copy the remaining elements of the other input file to the result file.
Problem 5 Solve this problem inside the files problem5-library.c and problem5-library.h. Do not modify any other files for this problem. Write a function called "nextLetter" inside problem5-library.c and add its prototype inside problem5-library.h. • The function must accept 2 parameters, a character then an integer. It will return a character. • The function will return the character that is reached by starting from the passed letter and moving steps equal to the passed integer. Check the examples below: Example: If the parameters were 'A' and 1, the function will return 'B', because 'B' is 1 step away from 'A'. Example: If the parameters were 'e' and 3, the function will return 'h', because 'h' is 3 steps away from 'e'. • If the given letter is uppercase, the returned letter must be uppercase. If the given letter is lowercase, the returned letter must be lowercase. • If the given integer is too big or will cause the letters to reach the last letter, you must restart the letters from…
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