396 views
1 votes
1 votes
Considering size of int as 2 Bytes and size of char as  1 Byte what will be the output

int main()

{

int a=300;

char *b=(char *)&a;

*==b=2;

printf("%d",a);

return 0;

}

2 Answers

0 votes
0 votes
I think error will come....you please check the code again
0 votes
0 votes
Ans 258

As a=300

we can write a

00000001 00101100

where  b will be point to Higher byte(00000001) so when we do ++b then it will point to LB(00101100) and then *b =2 so then final value of a =258(00000001 00000010)

No related questions found