Question

In: Computer Science

If x = 5, y = 6, z = 4, and w = 3.5, evaluate each...

  1. If x = 5, y = 6, z = 4, and w = 3.5, evaluate each of the following statements, if possible. If it is not possible, state the reason.
  1. ((++y) * z) % x
  1. (x % y) % (--z) a)    
  1. Static_cast<int> ((--y) + x / z)
  1. Static_cast<int> (w + Static_cast<double> (x / z + w))

Solutions

Expert Solution

In case of any queries,please comment. I would be very happy to assist all your queries.Please give a Thumps up if you like the answer.

1) Program


#include <iostream>

using namespace std;

int main()
{
int x = 5, y = 6, z = 4, w = 3.5;
cout<<((++y) * z) % x<<endl;

return 0;
}

Output

3

Here +++y gives 7

(++y)*z=7*4=28

28%3 =3, the answer

2) Program

#include <iostream>

using namespace std;

int main()
{
int x = 5, y = 6, z = 4, w = 3.5;
cout<<(x % y) % (--z) a)<<endl;

return 0;
}

Output

Error: Variable a is not declared

3) Program


#include <iostream>

using namespace std;

int main()
{
int x = 5, y = 6, z = 4, w = 3.5;
cout<<static_cast<int> ((--y) + x / z)<<endl;

return 0;
}

Output

6

4) Program


#include <iostream>

using namespace std;

int main()
{
int x = 5, y = 6, z = 4, w = 3.5;
cout<<static_cast<int> (w + static_cast<double> (x / z + w))<<endl;
return 0;
}

Output

7


Related Solutions

Please explain this prolog code line by line. union([X|Y],Z,W) :- member(X,Z), union(Y,Z,W). union([X|Y],Z,[X|W]) :- \+ member(X,Z),...
Please explain this prolog code line by line. union([X|Y],Z,W) :- member(X,Z), union(Y,Z,W). union([X|Y],Z,[X|W]) :- \+ member(X,Z), union(Y,Z,W). union([],Z,Z).
The following logic function is given as a sum of minterms F(W,X,Y,Z) = ∑W,X,Y,Z(7,8,10,11,13) + D(5,...
The following logic function is given as a sum of minterms F(W,X,Y,Z) = ∑W,X,Y,Z(7,8,10,11,13) + D(5, 9, 15). (25 points) a) Draw the K-Map and find the minimal sum-of-products expression for this function. b) Draw the circuit implementing this expression c) Give all input pair or pairs where transition between them would create a timing hazard d) Draw the timing diagram showing the glitch corresponding to the pair or one of the pairs. Assume ALL gate delays are equal e)...
Assume someone has a secret 4-tuple (w, x, y, z) where each number can be from...
Assume someone has a secret 4-tuple (w, x, y, z) where each number can be from 1 to 1000 inclusive. Your code is supposed to find what these integers are by using a loop and comparing the number (part of Brute Force). One approach is to write four nested for-loops to check for the number. This is O(n 4 ). Your task is to determine a random 4-tuple. Is your solution better than O(n^4 )? 1 import random as rn...
Consider the linear transformation T: R^4 to R^3 defined by T(x, y, z, w) = (x...
Consider the linear transformation T: R^4 to R^3 defined by T(x, y, z, w) = (x +2y +z, 2x +2y +3z +w, x +4y +2w) a) Find the dimension and basis for Im T (the image of T) b) Find the dimension and basis for Ker ( the Kernel of T) c) Does the vector v= (2,3,5) belong to Im T? Justify the answer. d) Does the vector v= (12,-3,-6,0) belong to Ker? Justify the answer.
Evaluate ∫ C ( 2 x − y ) d x + ( 4 y −...
Evaluate ∫ C ( 2 x − y ) d x + ( 4 y − x ) d y where C consists of the line segment from( 0 , 1 ) to ( 1 , 0 ), followed by the line segment from ( 1 , 0 ) to( 3 , 0 ), followed by the line segment from ( 3 , 0 ) to ( 2 , 2 ). Submit answer as a number rounded to two decimal...
Compute the derivative of the given vector field F. Evaluate the line integral of F(x,y,z) = (y+z+yz , x+z+xz , x+y+xy )
Compute the derivative of the given vector field F. Evaluate the line integral of F(x,y,z) = (y+z+yz , x+z+xz , x+y+xy )over the path C consisting of line segments joining (1,1,1) to (1,1,2), (1, 1, 2) to (1, 3, 2), and (1, 3, 2) to (4, 3, 2) in 3 different ways, along the given path, along the line from (1,1,1) to (4,3,2), and finally by finding an anti-derivative, f, for F.
For each of the formulas below, state whether it is true or false. a) pX,Y,Z(x,y,z)=pY(y)pZ∣Y(z∣y)pX∣Y,Z(x∣y,z)   ...
For each of the formulas below, state whether it is true or false. a) pX,Y,Z(x,y,z)=pY(y)pZ∣Y(z∣y)pX∣Y,Z(x∣y,z)       Select an option         True         False    b) pX,Y∣Z(x,y∣z)=pX(x)pY∣Z(y∣z)       Select an option         True         False    c) pX,Y∣Z(x,y∣z)=pX∣Z(x∣z)pY∣X,Z(y∣x,z)       Select an option         True         False    d) ∑xpX,Y∣Z(x,y∣z)=1       Select an option         True         False    e) ∑x∑ypX,Y∣Z(x,y∣z)=1       Select an option         True   ...
Find the coordinates of the point (x, y, z) on the plane z = 4 x...
Find the coordinates of the point (x, y, z) on the plane z = 4 x + 1 y + 4 which is closest to the origin.
Given function f(x,y,z)=x^(2)+2*y^(2)+z^(2), subject to two constraints x+y+z=6 and x-2*y+z=0. find the extreme value of f(x,y,z)...
Given function f(x,y,z)=x^(2)+2*y^(2)+z^(2), subject to two constraints x+y+z=6 and x-2*y+z=0. find the extreme value of f(x,y,z) and determine whether it is maximum of minimum.
Consider the following. x 1 2.5 3 4 5 1.5 y 1.5 2.2 3.5 3 4...
Consider the following. x 1 2.5 3 4 5 1.5 y 1.5 2.2 3.5 3 4 2.5 (a) Draw a scatter diagram for the following data. (Do this on paper. Your instructor may ask you to turn in this work.) (b) Would you be justified in using the techniques of linear regression on these data to find the line of best fit? Explain
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT