# C Programming :: Bitwise Operators

NA
SHSTTON
2
Solv. Corr.
2
Solv. In. Corr.
4
Attempted
0 M:0 S
Avg. Time

1 / 34

What is the output of the following 'C' program ?

#include
void main()
{
printf("%x",-1<<4);
}

Affff

Bfff0

CCompilation error

DNone of these

| | | Asked In |

Explanation:

"-1 is internally represented as all 1's. When left shifted four times the least" significant 4 bits are filled with 0's.
The %x format specifier specifies that the integer value be printed as a hexadecimal value.

Workspace

NA
SHSTTON
1
Solv. Corr.
3
Solv. In. Corr.
4
Attempted
0 M:0 S
Avg. Time

2 / 34

What is the output of the following 'C' program ?

#include
int main() {
int i=10;
i=!i>14;
printf("i=%d",i);
return 0;
}

AI = 0

B1 = 14

CI = 10

DI = 1

ENone of these

| | | Asked In |

Explanation:

In the expression !i>14 , NOT (!) operator has more precedence than ">"

symbol. ! is a unary logical operator. !i (!10) is 0 (not of true is false). 0>14 is false (zero).

Workspace

NA
SHSTTON
2
Solv. Corr.
2
Solv. In. Corr.
4
Attempted
0 M:0 S
Avg. Time

3 / 34

What is the output of the following 'C' program ?

#include
void main()
{
int i =0;j=0;
if(i && j++)
printf("%d..%d",i++,j);
printf("%d..%d,i,j);
}

A0..1

B1..2

C0..0

D1..0

ENone of these

| | | Asked In |

Explanation:

The value of i is 0. Since this information is enough to determine the truth value of the boolean expression.
So the statement following the if statement is not executed.
The values of i and j remain unchanged and get printed.

Workspace

NA
SHSTTON
4
Solv. Corr.
1
Solv. In. Corr.
5
Attempted
0 M:0 S
Avg. Time

4 / 34

What is the output of the following 'C' program ?

include
void main ()
{
int i = 32,j = 0x20, k, l, m;
k = i|j;
l = i & j;
m = k^l;
printf ("%d %d %d %d %d", i, j, k, l, m);
}

A32 32 32 32 0

B0 32 32 32 32

C0 0 0 0 0

D32 32 32 32 32

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
5
Solv. In. Corr.
5
Attempted
0 M:0 S
Avg. Time

5 / 34

What is the output of the following 'C' program ?

#include
void main ()
{
unsigned int m = 32;
printf("%d",~m);
}

Affff

Bffdf

C0

Dddfd

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
1
Solv. Corr.
3
Solv. In. Corr.
4
Attempted
0 M:0 S
Avg. Time

6 / 34

What would be the output of the following program ?

#include
void main ()
{
unsigned int a = 0xffff;
~a;
printf ("%x", a);
}

Affff

B00ff

C0

DNone of these

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
4
Solv. Corr.
0
Solv. In. Corr.
4
Attempted
0 M:0 S
Avg. Time

7 / 34

What is the output of the following 'C' program ?

#include
void main ()
{
unsigned char i = 0x80;
printf("\n%d", i << 1);
}

A0

B100

C256

DNone of these

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
2
Solv. Corr.
1
Solv. In. Corr.
3
Attempted
0 M:0 S
Avg. Time

8 / 34

What is the output of the following program ?

#include
void main() {
int k = -7;
printf(""%d"",0 }

A0

Ba non-zero value

Cis illegal

Dgarbage values

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
1
Solv. Corr.
2
Solv. In. Corr.
3
Attempted
0 M:0 S
Avg. Time

9 / 34

What is the output of the following 'C' program ?

#include
void main()
{
if(~0 == (unsigned int)-1)
printf("Hello");
}

ACompilation Error

BNo Ouput

CHello

DNone of these

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
3
Solv. In. Corr.
3
Attempted
0 M:0 S
Avg. Time

10 / 34

What is the output of the following 'C' program ?

#include
void main()
{
int i=4,j=7;
j = j || i++ && printf("YOU CAN");
printf("%d %d", i, j);
}

A4 4

B4 0

C4 1

DCompilation Error

| | | Asked In |

Explanation:

Here is no explanation for this answer

Workspace