C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - Find Output of Program (Q.No. 5)
5.
What will be the output of the program?
#include<stdio.h>
int main()
{
unsigned char i = 0x80;
printf("%d\n", i<<1);
return 0;
}
Discussion:
65 comments Page 7 of 7.
Shruti said:
1 decade ago
What is 0x80?
How do we conver it to binary?
How do we conver it to binary?
Tomek said:
1 decade ago
I got caught because I thought there would be overflow and it becomes 0. But char is converted to int before <<
Madureddy said:
1 decade ago
Yes Kasi is correct.
Kasi said:
2 decades ago
i = 0x80 = 00000000 10000000 in binary form.
After i<<1 it becomes 00000001 00000000. Its decimal equivallent is 256.
After i<<1 it becomes 00000001 00000000. Its decimal equivallent is 256.
Kee said:
2 decades ago
Pleases give the step.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers