Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 11, Problem 3E
Program Plan Intro
Program Plan:
- Include the necessary headers
- Define the required variables and methods
- Define the main function
- Call the method “int_size()” for displaying the size of the int.
- Define the method “int_size()”
- Declare the required variables.
- Perform the shift operation.
- Based on the result the counter value gets returned.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a function int bitset(int x, int n) to set nth bit of x to 1, if its (n-1)th bit is 1. if n <1 or n >15, the function will return -1 to thecalling function
Write a function that makes the base conversion. It takes two integers n and b as input (n >= 0 andb > 1, both in base 10) and expresses n in base b. For example, the decimal expansion of 345 inbase 10 is 345 = 3 × 102 + 4 × 101 + 5 × 100.Sample input: n = 12, b =2. Sample output: 1100Explanation: (12)10 = (1100)2
Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position
p set to the rightmost n bits of y, leaving the other bits unchanged.
Chapter 11 Solutions
Programming in C
Ch. 11 - Type in and run the four programs presented in...Ch. 11 - Write a program that determines whether your...Ch. 11 - Prob. 3ECh. 11 - Using the result obtained in exercise 3, modify...Ch. 11 - Write a function called b that takes two...Ch. 11 - Write a function called b that looks for the...Ch. 11 - Write a function called b to extract a specified...Ch. 11 - Prob. 8E
Knowledge Booster
Similar questions
- Given that a computer uses 4-bit ones’s complement numbers, what value will be stored in the variable j after the following code segment terminates? j = 1 k = -2 while(k != 0) { j = j + 1; k = k + 1; }arrow_forwardNumbers can be regarded as product of its factors. For example,8 = 2 x 2 x 2; = 2 x 4.Write a function that takes an integer nand return all possible combinations of its factors.Note:You may assume that n is always positive.Factors should be greater than 1 and less than n.Examples:input: 1output:[]input: 37output:[]input: 12output:[ [2, 6], [2, 2, 3], [3, 4]]input: 32output:[ [2, 16], [2, 2, 8], [2, 2, 2, 4], [2, 2, 2, 2, 2], [2, 4, 4], [4, 8]].arrow_forwardFor each of the following functionsC(n), indicate how much the Running TimeT(n) will change its input is increased fourfold. (a) √n3 (b) n3 (c) 3n d) log2n2arrow_forward
- BELOW MCQ GIVEN ANSWER CAN BE MORE THAN ONE OPTION. PLEASE PROVIDE CORRECT ANSWERS. ------------------- Q3 :- The ANSI C function below causes the program in which it runs to malfunction . Which of the following connection will help to perform function successfully ? /* Return a count of all the bits set in bytes */ int bitcount (unsigned char c) { unsigned char x , b , count =0; for (b = 0 , x= 1 ; !(x & 0x100); ++b, x <<=1) { if (x | c ) ++count; } return count; } A) change the type of x to a type larger than unsigned char. B) remove the extraneous variable b. C) change the return type to unsigned char . D) change if ( x | c) to if ( x & c) inside the for loop. E) change ! (c & 0x100) to ( x < 0x100) inside the for loop.arrow_forwardDraw out a TM (computable function) that does the following: - Input: Two binary string of equal length separated by # (example: 0110#1010) - Output: The result from performing logical AND on the two binary strings (0010). You may write the output on Tape 2.arrow_forwardSo this is a function that prints the two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers. (The output can be greater than a 32 bit integer.) I want detailed explanation on the part of the code that is in bold and underlined in the starting of the function (long sum = *arr; int min = *arr; int max = *arr;). I cant understand the purpose and the logic behind this specific initialization. Sample Input 1 2 3 4 5 Sample Output 10 14 The actual code- void miniMaxSum(int arr_count, int* arr) { long sum = *arr; int min = *arr; int max = *arr; for(int i = 1; i < arr_count; i++){ sum = sum + arr[i]; if(arr[i] > max){ max = arr[i]; } if(arr[i] < min){ min = arr[i]; } } printf("%ld %ld", sum - max, sum - min); }arrow_forward
- Write a function that would compute for the power given the base and the exponent. Take into consideration negative exponents. Sample output: Input the base: Input the power: Resultarrow_forwardWrite a function to determine the number of bits you would need to flip to convertinteger A to integer B.EXAMPLEInput:Output:SOLUTION29 (or: 11101), 15 (or: 01111)2arrow_forwardWrite a function that would compute for the power given the base and the exponent. Take into consideration negative exponents.arrow_forward
- Write a code which will take input as 2 numbers (INT first, INT second) and print 4 outputs (add, subtract, multiply, divide) applying following functions: a = first + second; s= first - second; m= first * second; d = first / second;arrow_forwardImplement the following Boolean function using a multiplexer. Use A, C and D as the select lines, where A is the MSB and D is the LSB. Answer the following questions. Include a systematic solution for you answer, if applicable. 1. Which of the following inputs are not connected to the ground? A. I0 B. I2C. I5D. More than one of the choicesE. None2. Which of the following inputs are connected to the complement of B?A. I0B. I4C. I7D. More than one of the choicesE. None 3. Which of the following inputs are connected to +5V or Vcc?A. I0B. I4C. I6D. More than one of the choicesE. None 4. What is the output when A=1, B=0, C=0 and D=1? A. +5VB. 0VC. B'D. More than one of the choicesE. Nonearrow_forwardImplement the following Boolean function using a multiplexer. Use A, C and D as the select lines, where A is the MSB and D is the LSB. Answer the following questions. Include a systematic solution for you answer, if applicable.1. Which of the following inputs are not connected to the ground?A. I2B. I5C. I6D. More than one of the choicesE. None 2. Which of the following inputs are connected to B?A. I0B. I1C. I3D. More than one of the choicesE. None 3. Which of the following inputs are connected to +5V or Vcc?A. I3B. I4C. I7D. More than one of the choicesE. None 4. What is the output when A=1, B=0, C=1 and D=0?A. +5VB. 0VC. B’D. More than one of the choicesE. Nonearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education