480 views

1 Answer

Best answer
2 votes
2 votes

Suppose integers are stored in 2 bytes. Signed int has range -32768 to 32767 AND Unsigned integers has range 0 to 65535.

signed int i =-13; 

Declares i to be signed integer and stores -13 in it.

unsigned int k= i%2;

Declares k to be unsigned integer and stores 65535 in it. 

i % 2 = (-13) % 2 = -1 and -1 is equal to 65535 in unsigned type.

printf("%d\n",k);

k is of unsigned type while format specifier is %d (not %u) therefore berfore printing k is again typecast to signed i.e. -1

hence answer C 
 

selected by

Related questions

2 votes
2 votes
1 answer
1
Khushboo Solanki asked May 11
121 views
Consider the following function:int arc(int i, int j){if(i<2) return j+2;else if(j<2) return arc(i-1, 1);else return arc(i-1, arc(i, j-2));}The value returned by arc(2, 6...
0 votes
0 votes
1 answer
3
Debargha Mitra Roy asked Apr 16
186 views
#include <stdio.h int main() { int a[3] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)T...