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 output of the following statetment?Printf(“%x”,
-1<<4); ?

Answers were Sorted based on User's Feedback



what is output of the following statetment?Printf(“%x”, -1<<4); ?..

Answer / sasmita lenka

Answer fff0.........As -1 is internally represented as as
all 1's.When left shifted four times the least significant 4
bits are filled with 0's.The %x format specifier specifies
that the integer value be printed as a hexadecimal value.

Is This Answer Correct ?    14 Yes 1 No

what is output of the following statetment?Printf(“%x”, -1<<4); ?..

Answer / ankurmohansharma

In case of 16- bit compiler answer will be fff0
In case of 32-bit compiler answer will be fffffff0.

Reason being same as of above two

Is This Answer Correct ?    7 Yes 0 No

what is output of the following statetment?Printf(“%x”, -1<<4); ?..

Answer / vignesh1988i

here the equivalent representation for -1 in memory is it's
two's compliment notation..... so alll the 16 bits will be
HIGH (1).... so four time we are moving the bits left
side.... so after that it will result as 65520.... the
equivalent HEX value for 65520 will get printed.........



thank u

Is This Answer Correct ?    5 Yes 4 No

what is output of the following statetment?Printf(“%x”, -1<<4); ?..

Answer / arupananda

Question is -1<<4
Answer to 16bit compiler
As -1 is a negative number,so compiler first convert this number with removing negative sign to 2's complement
Here -1 is given
so compiler first removes the -ve sign and then convert to 2's complement
Binary form of 1 for 16 bit compiler is 0000 0000 0000 0001
1's complement of 1 is 1111 1111 1111 1110
2's complement of 1 is 1111 1111 1111 1111(1+1's complement)
now do the left shift operation
1111 1111 1111 1111 << 4
which results 1111 1111 1111 0000
i.e equivalent to FFF0 in hex format
So the answer is FFF0 for 16 bit compiler
And for 32 bit compiler it is FFFF FFF0 (do same operation as 16 bit compiler)

Is This Answer Correct ?    1 Yes 1 No

what is output of the following statetment?Printf(“%x”, -1<<4); ?..

Answer / ranjith

-1 is stored as '1' 32 times [i.e. ffffffff], doing a left
shift 4 times results in '1' 28 times followed by 4 zeros.
[i.e. in hexadecimal ffffffff0].

Therefore the output for the above printf is fffffff0.

Thanks,
Ranjith

Is This Answer Correct ?    5 Yes 6 No

Post New Answer

More C Interview Questions

How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,


Efficient data structure for store/search list of 1000 records a)array b)double linked list c)circular queue d)hash table

3 Answers   Value Labs,


Write a program to print the prime numbers from 1 to 100?

7 Answers  


what is object oriental programing?

1 Answers  


What is enumerated data type in c?

0 Answers  


what is the differance between pass by reference and pass by value.

7 Answers   Infosys,


Difference between Function to pointer and pointer to function

0 Answers  


Why is c fast?

0 Answers  


What are the uses of null pointers?

0 Answers  


What is the right way to use errno?

0 Answers  


What is the general form of #line preprocessor?

0 Answers  


#define f(x) main() { printf("\n%d",f(2+2)); }

5 Answers  


Categories