3,106 views

4 Answers

1 votes
1 votes
short variable has a 16-bit size. in a little-endian system, 320 (=00000001 01000000b) will be stored as 01000000 in the first location and  00000001 in the next location.

char variable stores 8 bits and points to 01000000 whose equivalent decimal value is 64. Thus output will be 64
edited by
0 votes
0 votes

 

Here, (C) is the answer.

Here, a = $(320)_{10}$ = $(0000000101000000)_{2}$ = $(0140)_{16}$.

Short data type takes 2 bytes of memory.

*ptr is char pointer which points to the 1 byte memory location of stored value of variable a.

In little-endian representation of stored data is as least significant byte of stored value will be stored in first memory location and second least byte will be stored on subsequent memory locations and so on.

Refer, Endianness for more clarity on little-endian.

Suppose address of variable a is start at location A in byte addressable memory architecture. than $(40)_{16}$ will be store at location A and $(01)_{16}$ will be stored at address A+1 .

 

Little-Endian representation
$(40)_{16}$ $(01)_{16}$

 

Here, ptr points to the memory address A.

Here, *ptr prints the integer value of the byte stored on location A. which is $(40)_{16}$ = $(64)_{10}$.

 

 

 

0 votes
0 votes

We know in binary 320 = 00000001 01000000 .

In little – endian we take values from the LSB , char will take 1 byte , so 01000000  will be taken  = 64.

Answer – C :  64

Related questions

0 votes
0 votes
1 answer
1
SSR17 asked Feb 29
210 views
#include <stdio.h int main() { int i = -1; int x = (unsigned char)i; printf("%d", x); return 0; }output is 255 , but please explain how
2 votes
2 votes
1 answer
2
rupamsardar asked Aug 30, 2023
468 views
#include <stdio.h int f(int x) { if(x%2==0) { return f(f(x-1)); } else return (x++); } int main() { printf("%d",f(12)); ret...
5 votes
5 votes
2 answers
3
saurabh0709 asked Aug 1, 2023
1,136 views
What will be the output of the following code? _______ #include <stdio.h int main(){ char val=250; int ans; ans= val+ !val + ~val + ++val; printf("%d", ans); return 0; }
2 votes
2 votes
1 answer
4