edited by
1,151 views
1 votes
1 votes
<code>#include <stdio.h>
        int main()
        {
            unsigned int b = 20;
            b = ~b;
            printf("%d\n", b);
        }</code>
edited by

1 Answer

Best answer
6 votes
6 votes
unsigned int b=0000000000010100 (assuming int = 2 bytes)

b=~b, therefore b=1111111111101011

now %d specifier does not know anything about signed or unsigned, it just assume that the given number is in signed 2's complement form..

and hence value returned will be -21...
selected by

Related questions

1.7k
views
1 answers
2 votes
Nishi Agarwal asked Mar 10, 2019
1,653 views
int main() { int m=44; int *p=&m; int &r=m; int n=(*p)++; int *q=p-1; r=--*(p)+1; ++*q; printf("m=%d n=%d r=%d",m,n,r); return 0; } Options:$m=44,\ n=46,\ r=45$m=45,\ n=44,\ r=45$m=46,\ n=44,\ r=46$m=46,\ n=43,\ r=46$
1.3k
views
2 answers
2 votes
Khushal Kumar asked Jul 8, 2017
1,331 views
#include<stdio.h> int main(void){ int a = 1, 2, 3; printf("%d", a); return 0;}
1.3k
views
2 answers
3 votes
Aghori asked Jul 14, 2017
1,258 views
#include <stdio.h> int main() { int *p = (int *)20; int *q = (int *)30; printf("%d", q - p); }Explain which one of the following is correct?Compilation error.102None of there.