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 |
What is the full form of getch?
Explain the properties of union.
write a program to sort the elements in a given array in c language
I heard that you have to include stdio.h before calling printf. Why?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
different between overloading and overriding
how does the C compiler interpret the following two statements p=p+x; q=q+y; a. p=p+x; q=q+y b. p=p+xq=q+y c. p=p+xq; q=q+y d. p=p+x/q=q+y
What is the purpose of scanf() and printf() functions?
what will be the output of this program main() { int i=1; while (i<=10); { i++; } }
write a c program to find the roots of a quadratic equation ax2 + bx + c = 0
11 Answers CSC, St Marys, TATA,
what is data structure.in linear and non linear data structures which one is better?Explain
Does c have circular shift operators?