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 2 of 7.
Divya S said:
1 decade ago
Nice explanation kasi. Thanks.
Swathi said:
1 decade ago
How to convert 0x88 int obinary can any one explain please ?
Apurva Nigam said:
1 decade ago
@Swathi:
to conevrt hex to binary u need to take each digit of hex value and write its binary equivalent.
For eg:-
if hex = 88 , its binary would be
bin = 1000 1000
since binary equivalent of 8(decimal) is 1000.
example2:-
if hex = AF , its binary equi is
bin = 1010 1111
as binary equi of 'A'(in decimal system its 10) 1010 and that of 'F'(in decimal its 15) is 1111
Hope this will help u.
Take care :)
to conevrt hex to binary u need to take each digit of hex value and write its binary equivalent.
For eg:-
if hex = 88 , its binary would be
bin = 1000 1000
since binary equivalent of 8(decimal) is 1000.
example2:-
if hex = AF , its binary equi is
bin = 1010 1111
as binary equi of 'A'(in decimal system its 10) 1010 and that of 'F'(in decimal its 15) is 1111
Hope this will help u.
Take care :)
Nikita said:
1 decade ago
char converted to int before <<
What happens if float or double is there?
What happens if float or double is there?
Siva said:
1 decade ago
Nice explination apurva.
Sunil sharma,kaverinagar said:
1 decade ago
What do you mean by 0*80?
Shanthi said:
1 decade ago
How would you convert binary into decimal (0000 0001 0000 0000=256) ?
ULLAS K said:
1 decade ago
@nikita.
Bitwise operator can't be applied to float and double type. This its limitation,
Check out in books.
Bitwise operator can't be applied to float and double type. This its limitation,
Check out in books.
Kunal said:
1 decade ago
What is the binary value of x (hexadecimal no) ?
Mayuri said:
1 decade ago
Char is 1byte in size. Then why everyone having explanation assuming it is 2 byte ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers