C Programming - Bitwise Operators - Discussion

Discussion Forum : Bitwise Operators - Find Output of Program (Q.No. 9)
9.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int i=32, j=0x20, k, l, m;
    k=i|j;
    l=i&j;
    m=k^l;
    printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);
    return 0;
}
0, 0, 0, 0, 0
0, 32, 32, 32, 32
32, 32, 32, 32, 0
32, 32, 32, 32, 32
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
28 comments Page 2 of 3.

Rams said:   1 decade ago
j=0x20=(20)H
hexadecimal to decimal=(2*16^1)+(0*16^0)=32+0=32;
i=32;
j=32;
k=i|j=10000|10000=10000=32
l=1&j=10000&10000=32
m=k^i=10000^10000=00000=0

Basamma said:   10 years ago
Hi @Charu.

We can write 80 as 1000 0000.

Now assigning decimal value to above binary number as:

128 64 32 16 8 4 2 1.

Means --> Value of 0*80 is 128.

Bhagyashri Ghalme said:   1 decade ago
I am not satisfied by the above answer. So please somebody help me to get perfect answer of the above question.

Lokesh said:   7 years ago
Here 0x20 means convert the decimal number to hexadecimal number we already know that 20 in hexadecimal as 32.

Arup said:   1 decade ago
@Priyanka
0x20 is a hexadecimal number
First convert to Binary i.e 0010 0000 and make to decimal i.e. 32

Uday said:   1 decade ago
Please explain conversions on binary to decimal and decimal to hexadecimal and vice versa.

Rajeev kuamr said:   1 decade ago
Give me some more concept about convertion of hexadecimal to decimal.

Sam said:   7 years ago
How 100000!?

100000=100000 (32)? the answer should be 1000000 (64).

Ashmita said:   10 years ago
Please explain 0x20 where is define 0*20 is a hexadecimal.

Priyanka said:   1 decade ago
Someone please explain how 0*20 means 2 hexa decimals.


Post your comments here:

Your comments will be displayed after verification.