Skip to content
Related Articles
Open in App
Not now

Related Articles

ISRO | ISRO CS 2020 | Question 25

Improve Article
Save Article
  • Last Updated : 04 Sep, 2020
Improve Article
Save Article

What is the output of the following ‘c’ code assuming it runs on a byte addressed little endian machine?




#include <stdio.h>
int main( )
 {
   int x; char *ptr;
   x = 622,100,101;
   printf("%d", (*(char *)&x) * (x % 3));
   return 0;
 


(A) 622
(B) 311
(C) 22
(D) 110


Answer: (D)

Explanation: In little endian machines, last byte of binary representation of the multibyte data-type is stored first.

So, x = 622,100,101 will be stored as 101,100,622 (lower byte will be stored first.).
Hence, printed value will be 101.




#include <stdio.h>
int main( )
 {
   int x; char *ptr;
   x = 622,100,101;
   printf("%d", (*(char *)&x) * (x % 3));
   return 0;
 }


Option (D) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!