C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - Find Output of Program (Q.No. 6)
6.
What will be the output of the program?
#include<stdio.h>
int main()
{
printf("%d >> %d %d >> %d\n", 4 >> 1, 8 >> 1);
return 0;
}
Discussion:
36 comments Page 4 of 4.
Deepika said:
1 decade ago
Thanks Neetu.....
Mukesh said:
1 decade ago
2 >> 4 rest depends on the compiler..
Maruti shrivastava said:
1 decade ago
Very thanks to you neetu.
Divya s said:
1 decade ago
Yes neetu understood thanks
Sundar said:
1 decade ago
I got the following outputs:
In GCC (32-bit platform): 2 >> 4 134513662 >> 134513904
Turbo c (16 bit platorm): 2 >> 4 0 >> 344
Therefore, 2 >> 4 garbagevalue >> garbagevalue is the correct answer.
In GCC (32-bit platform): 2 >> 4 134513662 >> 134513904
Turbo c (16 bit platorm): 2 >> 4 0 >> 344
Therefore, 2 >> 4 garbagevalue >> garbagevalue is the correct answer.
Neetu said:
1 decade ago
4 = 0100 now shift to right 1 time. It will become 0010 = 2.
8 = 1000 now shift to right 1 time. It will become 0100 = 4.
Rest is garbage, so the answer is C.
8 = 1000 now shift to right 1 time. It will become 0100 = 4.
Rest is garbage, so the answer is C.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers