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
Answers were Sorted based on User's Feedback
Answer / 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 |
Find MAXIMUM of three distinct integers using a single C statement
What is the stack in c?
What is a program flowchart?
What is the code for 3 questions and answer check in VisualBasic.Net?
What are the features of the c language?
1 232 34543 4567654 can anyone tell me how to slove this c question
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
Program to trim a given character from a string.
How do you determine a file’s attributes?
What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); }
what is the difference between structure and union?
How can I split up a string into whitespace-separated fields?