Question

Consider the following C program: int maino short S; printf(Address of S is %d\n, &S); // printf() Statement 1 printf(%d,

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Little Endian and Big Endian are used to storing multibyte data type.In Little Endian, least significant byte is read while in Big Endian, most significant byte is read.As we know "short" data type takes 2 Bytes but here we are using "Little Endian" hence only 1 least significant byte will be read.

Here "s" is stored on address 5865 and data is 182.

182 in 2 Byte binary= 00000000 10110110

Now take least significant 1 Byte(8 bits)= 10110110

But "s" is 2 byte 2's compliment short integer. Hence decimal value of 10110110 (2's compliment representation) = -74

"%d" in statement 2 shows that it will print a integer value.

Hence statement 2 will print -74 (negative 74)

Add a comment
Know the answer?
Add Answer to:
Consider the following C program: int maino short S; printf("Address of S is %d\n", &S); //...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 9. Which of the following is true for the following program? #include <stdio.h> int maino int...

    9. Which of the following is true for the following program? #include <stdio.h> int maino int i = 1; switch (0) case 1: printf("%d", 0); case 2: printf("%d", 0); case 3: printf("%d", 0); default: printf("%d", 1); return 0; } (2 points) The program has no error, the output is 1111 The program has no error, the output is 1 The program produces a compile time error, because there are no break statements The program produces a compile time error, because...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT