in Programming in C
3,124 views
3 votes
3 votes

in Programming in C
by
3.1k views

4 Answers

1 vote
1 vote
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
by

3 Comments

01000000 will be sxtored in the first location or 00000001 will be stored in first location in little-endian?i am confused in this.
0
0

Big Endian

Little Endian

 value 0x01 23 45 67 is represented as

      01   23   45  67

    67  45   23  01

Lowest Numeric address stores

MSB

LSB

Starting address of data item

Same in both

Same in both

features

String comparison.

Ordering of integers and strings.

Human readable

has to perform addition when it converts a 32-bit integer address to a 16-bit integer address, to use the least significant bytes

Higher-precision arithmetic.

Always reads as the same value if reading in the size larger than or equal to the value.

Intel

ARM, PowerPC (by Motorola) and SPARK (by Sun);

Current versions are bi endian

1
1
thankyou :)
0
0
0 votes
0 votes
320 write in binary form since ptr takes 8 bytes it is 64
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