C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - Find Output of Program (Q.No. 11)
11.
What will be the output of the program?
#include<stdio.h>
int main()
{
unsigned int res;
res = (64 >>(2+1-2)) & (~(1<<2));
printf("%d\n", res);
return 0;
}
Discussion:
24 comments Page 3 of 3.
Pgk said:
1 decade ago
thank u very much datta
Gugan said:
1 decade ago
I think answer is
1000 0000>>1) & (~(0000 0001<<2)
(0100 0000)& (~(0000 0100))
(0100 0000) & (1111 1011) ( ~ equal to NOT )
0100 0000=64(in decimal)
1000 0000>>1) & (~(0000 0001<<2)
(0100 0000)& (~(0000 0100))
(0100 0000) & (1111 1011) ( ~ equal to NOT )
0100 0000=64(in decimal)
Naveen said:
1 decade ago
Datta very thanks
Datta said:
2 decades ago
(64>>(2+1-2)) & (~(1<<2)) becomes
(64>>1) & (~(1<<2)).
In binary,
(0100 0000>>1) & (~(0000 0001<<2)
(0010 0000) & (~(0000 0100))
0010 0000 & 1111 1011 ( ~ equal to NOT )
0010 0000 = 32 (in decimal)
(64>>1) & (~(1<<2)).
In binary,
(0100 0000>>1) & (~(0000 0001<<2)
(0010 0000) & (~(0000 0100))
0010 0000 & 1111 1011 ( ~ equal to NOT )
0010 0000 = 32 (in decimal)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers