Question

Assume that x and y are already defined as being of type char . Write a...

Assume that x and y are already defined as being of type char . Write a single expression that will return true if the lower four bits of x are each the opposite of the lower four bits of y (x has a 0 where y has a 1 and vice versa). [Note that this compiler doesn't accept binary constants , so use hexidecimal instead. I.e., for 0b00111111 use 0x3F.]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

expression: if(((x^y)*16) == 0xF0)

all the bits in x^y are 1's if each bits in x and y are compelement to each other, but we need to check only last 4 bits.

Hence, (x^y)*16, will shift the bits on the right side. Hence, last 4 bits are all 1's then answer should be F0.

Add a comment
Know the answer?
Add Answer to:
Assume that x and y are already defined as being of type char . Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 4 (2 points) Consider the C statements below. Assume x has been assigned a value....

    Question 4 (2 points) Consider the C statements below. Assume x has been assigned a value. int mask = 0xFF000000; y = x ^ mask; Which one of the following best describes the value computed for variable y? Question 4 options: y contains the most significant byte of x complemented, with the rest of the bits unchanged y contains the most significant byte of x unchanged, with the rest of the bits 0 y contains the most significant byte of...

  • for java 12) Suppose you have defined variables int x 42 String y ="lunchtime" a) Evaluate...

    for java 12) Suppose you have defined variables int x 42 String y ="lunchtime" a) Evaluate each expression below y.equals ("breakfast") 11 x !-42 5 1 (y.length )>0 66 ! (x < =0)) x !( (x>0 GG x > 1) || x > 2) b) Using the variables x and y above, for each phrase below, write a Java boolean expression that captures its meaning. Then determine whether the expression is true or false using the values of x and...

  • Name: True/False & Multiple Choice (2 points each) (True / False ) 2 A char literal...

    Name: True/False & Multiple Choice (2 points each) (True / False ) 2 A char literal '2', a string literal "2", and the numeric literal 2 are identical and stored the same way though they are different types. 3 Since comments do not affect the program execution, you don't need to have it at all. 4. After the following statements are executed, the value of the variable rem is 3. 1. A preprocessor directive line starts with a pound sign...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • C PROGRAM When you print out the old and new bitsets, which are of type unsigned...

    C PROGRAM When you print out the old and new bitsets, which are of type unsigned char, please use the %p control character in the printff statement rather than %x or %d or %c. The compiler will complain, but we don't always listen to them anyway. The difference is it will print the bitset out in hex with a preceeding %0x. unsigned char bitset = 0x14 ; printf("Bitsrt is %p\n", bitset) ; results in Bitset is 0x14, which is what...

  • In C++. Write a class named FBoard for playing a game, where player x is trying to get her piece to row 7 and player o i...

    In C++. Write a class named FBoard for playing a game, where player x is trying to get her piece to row 7 and player o is trying to make it so player x doesn't have any legal moves. It should have: An 8x8 array of char for tracking the positions of the pieces. A data member called gameState that holds one of the following values: X_WON, O_WON, or UNFINISHED - use an enum type for this, not string (the...

  • First Assignment (due Thursday January 17) 1. Evaluate the following expression: 9+4X2/ (Y+1)-3Z where X 3,...

    First Assignment (due Thursday January 17) 1. Evaluate the following expression: 9+4X2/ (Y+1)-3Z where X 3, Y-5, Z-2 2. Solve the following equation for X where s 3, X-8 and z1. Invent a study with a psychologically relevant variable, such as compliance, aggression cooperation, happiness, etc. as the dependent variable. (In other words your dependent variable should not being something like course grade of blood pressure level, even if you independent variable is psychologically relevant). For example, you may want...

  • The last 3 cases are tests .cpp files to test the code. The language of this...

    The last 3 cases are tests .cpp files to test the code. The language of this code must be C++ because that is the only I am familiar with. Soreland, a software company, is planning on releasing its first C++ compiler with the hopes of putting MiniSoft's Visual C++ out of business (that reminds me of another story). Consequently, Soreland has contracted with the Fruugle Corporation to design and build part of their compiler. Of course, since Fruugle gets all...

  • You will write the following files: mystack.h - contains the class definition for the mystack class....

    You will write the following files: mystack.h - contains the class definition for the mystack class. mystack.cpp - contains the definitions for member functions of the mystack class. inpost.cpp - contains your convert() function. inpost.h - contains the function prototype for convert() so that the main() can call it. Each of the files (with the exception of inpost.h) is described in more detail below. All header files should contain header guards to prevent them from being included multiple times in...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT