what is the output of below code
int x=8,y;
x>>=2;
y=x;
what is y value.
NOTE:EXPLANATION IS COMPALSARY with binary bits
Answer Posted / kittu
x=8 means x is equivalent to 00001000 in bit wise environment.
x>>=2 is equivalent to x=(x>>2)
x>>2 makes a bitwise shift to x 2 times.that is now the bit
code is 00000010. that is 2.
and this is assigned to x.So when y is assigned by x viz
y=x; y value gets changed to 2.
Hence 2 is printed.
EXPLANATION:-When >> (right shift operator) is applied to a
byte
the bits in the byte get shifted to right by the number
specified on right side..
Ex:- 6>>1 implies
binary code of 6 is : 00000110
when shifted right : 00000011 which is 3 that is 6 divided
by 2.
Note that when shift operator is used the bits shift but not
rotate...That is once shift operator is applied the bits get
lost...
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is calloc() function?
i have a written test for microland please give me test pattern
What is an endless loop?
What type of function is main ()?
How is a pointer variable declared?
Write a function that will take in a phone number and output all possible alphabetical combinations
How is actual parameter different from the formal parameter?
Why is struct padding needed?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What are identifiers in c?
Is c language still used?
Is it better to use malloc() or calloc()?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
How do you define CONSTANT in C?
show how link list can be used to repersent the following polynomial i) 5x+2