A.
Explanation of Solution
“C” Expression for “K = 17”:
The C expression to perform the multiplications for “K = 17” is shown below
Expression: (x << 4) + x
A complete program has been developed to perform the multiplication with “K = 17” is shown below:
//Header file
#include <stdio.h>
#include <assert.h>
//Function definition for part A that is K = 17
int partA(int x)
{
//Returns the value by using "(x << 4) + x"
return (x << 4) + x;
}
//Main function
int main(int argc, char* argv[])
{
//Assign the value for "x"
int xValue = 0x12345678;
/* Call function "partA" with checking value using assert function */
assert(partA(xValue) == 17 * xValue);
return 0;
}
The given code is used to multiply integer variable “x” by constant factor “K = 17”...
B.
Explanation of Solution
“C” Expression for “K = -7”:
The C expression to perform the multiplications for “K = -7” is shown below
Expression: x - (x << 3)
Program:
A complete program has been developed to perform the multiplication with “K = -7” is shown below:
//Header file
#include <stdio.h>
#include <assert.h>
//Function definition for part B that is K = -7
int partB(int x)
{
//Returns the value by using "x - (x << 3);"
return x - (x << 3);
}
//Main function
int main(int argc, char* argv[])
{
//Assign the value for "x"
int xValue = 0x12345678;
/* Call function "partB" with checking value using assert function */
assert(partB(xValue) == -7 * xValue);
return 0;
}
The given code is used to multiply integer variable “x” by constant factor “K = -7”...
C.
Explanation of Solution
“C” Expression for “K = 60”:
The C expression to perform the multiplications for “K = 60” is shown below
Expression: (x << 6) - (x << 2)
Program:
A complete program has been developed to perform the multiplication with “K = 60” is shown below:
//Header file
#include <stdio.h>
#include <assert.h>
//Function definition for part C that is K = 60
int partC(int x)
{
//Returns the value by using "(x << 6) - (x << 2)"
return (x << 6) - (x << 2);
}
//Main function
int main(int argc, char* argv[])
{
//Assign the value for "x"
int xValue = 0x12345678;
/* Call function "partC" with checking value using assert function */
assert(partC(xValue) == 60 * xValue);
return 0;
}
The given code is used to multiply integer variable “x” by constant factor “K = 60”...
D.
Explanation of Solution
“C” Expression for “K = -112”:
The C expression to perform the multiplications for “K = -112” is shown below
Expression: (x << 4) - (x << 7)
Program:
A complete program has been developed to perform the multiplication with “K = -112” is shown below:
//Header file
#include <stdio.h>
#include <assert.h>
//Function definition for part D that is K = -112
int partD(int x)
{
//Returns the value by using "(x << 4) - (x << 7)"
return (x << 4) - (x << 7);
}
//Main function
int main(int argc, char* argv[])
{
//Assign the value for "x"
int xValue = 0x12345678;
/* Call function "partD" with checking value using assert function */
assert(partD(xValue) == -112 * xValue);
return 0;
}
The given code is used to multiply integer variable “x” by constant factor “K = -112”...
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- Write a function which returns “odd” or “even” for odd or even inputs, respectively. HINT: evenOrOdd(2) returns “even” and evenOrOdd (7) returns “odd” please you use pythonarrow_forwardUsing Python Write a program using functions to read a number N and print all its divisors.Example Input:N = 24Example Output:Divisors are: 1, 2, 3, 4, 6, 8, 12, 24arrow_forwardπ can be computed using the following series: m(i) = 4(1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + . . . + (-1)i+1/(2i - 1) ) Write a function that returns m(i) for a given i and write a test program that displays the following table: i m(i)1 4.0000101 3.1515201 3.1466301 3.1449401 3.1441501 3.1436601 3.1433701 3.1430801 3.1428901 3.1427arrow_forward
- Suppose we have the function g (n) = 6n + 5n2 + 3n3. Below are a number of statements regarding how the function grows depending on n. See pict Which / which of the above statements is true? Only statements A, B and F are correct Only statements A, C and E are correct Only statements B and D are correct Only statements B, C, D and F are correctarrow_forwardGoing missing Some calculations involving blank values may give different results to what you might expect. For example, when you pass a blank value into the AND() function, it is treated as TRUE. This is often unhelpful. To make blanks behave in a sensible way in calculations, you must first convert them to be "not available" using NA(). This function takes no inputs, and returns a missing value. To convert a blank value to a missing value, use this pattern. =IF(ISBLANK(cell), NA(), cell) Instruction In column H, use AND() to find women who have kids and get benefits. In column I, convert the blanks in column G to missing values. In column J, again find women who have kids and get benefits, this time using column I rather than G. please show the formula used to "has kids and gets benefits" , "gets benefits with missing values", has kids and gets benefits". Thank you Is non-white Has over 12 years of school? Is married? Has kids? Has young kids? Is head of household? Gets…arrow_forwardWrite a function “func(n)” that returns the number of values generated until all values are obtained as a function of the range of possible values n, using harmonic (n) belowarrow_forward
- Using Java The majority() function takes three boolean arguments and returns true if two (or more) of the arguments are true; and false otherwise. Complete two implementations of majority() below by filling in the letter of one of the expressions below in each provided space. You may use each letter once, more than once, or not at all (but you may not use any other code). A. false G. x && y H. x && z I. y && z J. x && y && z K. x || y B. true C. X D.y E. Z L.x || Z M. y || z N. x || y || z O. count++ wwwmmin P. count- Q. count R. count = 2arrow_forwardGiven a and b are int variables and c is a double variable. The initial value for a, b, and c are 8, 4, and 2.5. Show the working steps and result for the following expression:(i) a + b++ - carrow_forwardLet T₁ and 72 be any regular expressions. Which of the following equivalencies does NOT hold? Recall that r₁ = r2 iff L (₁) = L(T₂). O (ri+r₂)* = (ri+r₂)* (₁ + r₂)* = (r₂ + r₁)* (r₁+T₂)* = (ri + r₂) ○ (r₁+r₂)* = (r¡ +r₂)* Clear my choice Oarrow_forward
- The pseudocode for implementing the Taylor series expansion is shown below. The pseudocode is designed to return the value of the value of e* correct to two decimal places. This also requires the use of the factorial function created in the previous section. INPUT x, OUTPUT ExpVal % Initial computation n- 0, xold - 0 xnew - xold + (x^n)/nl error = |xnew - xold| xold = xnew n-1 %Successive computations WHILE error 2 0.001 xnew - xold + (x^n)/nl error |xnew - xold xold - xnew n=n+1 END WHILE ExpVal = xnew Question 10: Write a script taylor.m that computes the value of the function e* for a given user input x. Provide La proof that your script works.arrow_forwardb) You are given the task of analyzing how joyful a person is. If you are given a list of numbers that represent the emotional value of an individual on each day, design a divide and conquer algorithm to find the most joyous interval of the person. The measure of joy is given as sum of the values in interval multiplied by the smallest integer in the interval.arrow_forwardF(x.y,z)=x'y'z+x'yz+xy'z'+xy'z can you simplify this and draw the diagram of the simplified functionarrow_forward
- 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