Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

If null and 0 are equivalent as null pointer constants, which should I use?

1225


the question is that what you have been doing all these periods (one year gap)

2092


What is the g value paradox?

1176


How can you avoid including a header more than once?

988


Why is c fast?

1070


Can two or more operators such as and be combined in a single line of program code?

1375


What does c mean in standard form?

1185


What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file

1118


Why c is known as a mother language?

1088


What are the types of arrays in c?

1181


write a c program to find the sum of five entered numbers using an array named number

2144


What is difference between union All statement and Union?

1113


What is the right way to use errno?

1060


what are the facialities provided by you after the selection of the student.

2265


How can I swap two values without using a temporary?

1110