C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - Find Output of Program (Q.No. 2)
2.
If an unsigned int is 2 bytes wide then, What will be the output of the program ?
#include<stdio.h>
int main()
{
unsigned int m = 32;
printf("%x\n", ~m);
return 0;
}
Discussion:
35 comments Page 3 of 4.
Vignesh said:
1 decade ago
What does "f"&"d" mean and any thing others.
Jagajjeevan said:
1 decade ago
~a=-(a+1)
~32=-(32+1)=-33
Binary of 33 : 0000 0000 0001 0001
1's of 33 : 1111 1111 1110 1110
2's of 33(-33): 1
1111 1111 1110 1111
f f d f
~32 is ffdf
~32=-(32+1)=-33
Binary of 33 : 0000 0000 0001 0001
1's of 33 : 1111 1111 1110 1110
2's of 33(-33): 1
1111 1111 1110 1111
f f d f
~32 is ffdf
Jayakrishana said:
1 decade ago
Thanks for you explanation Sudheer Kumar Raina.
Chinnu said:
1 decade ago
Thanks munni thanku so much.
Sanjay said:
1 decade ago
Good explain munni.
Sudhir kushwaha said:
1 decade ago
m=32
In binary: 0000 0000 0010 0000
~ it called tiled i.e. 1's complement of given no.
Hence ~m : 1111 1111 1101 1111
f f d f
Hence C is answer
In binary: 0000 0000 0010 0000
~ it called tiled i.e. 1's complement of given no.
Hence ~m : 1111 1111 1101 1111
f f d f
Hence C is answer
Shilpa said:
1 decade ago
Thanks Neetu & Sudheer Kumar Raina, very well explianed.
NEERAJ KUMAR said:
1 decade ago
Thank nitu
Munni said:
1 decade ago
m=32
Hence C is answer.
In binary: 0000 0000 0010 0000
Hence ~m : 1111 1111 1101 1111
f f d f
Hence C is answer.
Abani said:
1 decade ago
Binary representation of 32 in 16bit(turbo c) is 0000000000100000
Hence 1's complement of 32 is 1111111111011111 and whose hexadecimal form is FFDF which is option C.
Hence 1's complement of 32 is 1111111111011111 and whose hexadecimal form is FFDF which is option C.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers