2 votes 2 votes #include int main() { char *x; x = (char *) &a; a = 512; x[0] = 1; x[1] = 2; printf("%d\n",a); return 0; } What is the output of above program? (a) Machine dependent b) 513 (c) 258 (d) Compiler Error Programming in C programming-in-c + – Akriti sood asked Jan 11, 2017 Akriti sood 553 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply utk0203 commented Jan 11, 2017 reply Follow Share Obvio it will be compilation error , you are using undeclared a 0 votes 0 votes dd commented Jan 11, 2017 reply Follow Share ............................ 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes Assuming a is declared first. In a system that uses little-endian (Like Intel x86 processors ) the answer should be $513$ In a system that uses big-endian (Like IBM z/Architecture mainframes ) the answer should be a very large value. Answer should be (a) Machine dependent dd answered Jan 11, 2017 dd comment Share Follow See all 4 Comments See all 4 4 Comments reply Akriti sood commented Jan 11, 2017 reply Follow Share debashish,how do u know that it is endian notation?? 0 votes 0 votes Akriti sood commented Jan 11, 2017 reply Follow Share and if 'a' is a int variable then how will x[0] and x[1] work?? i mean a is an integer type variable,so what will be x[0] or x[1] refer to?? 0 votes 0 votes Kapil commented Jan 11, 2017 reply Follow Share @Akriti A prerequisite to know what is happening https://gateoverflow.in/4273/char-pointer-to-access-an-int 0 votes 0 votes Akriti sood commented Jan 11, 2017 reply Follow Share thanks @kapil.. 1 votes 1 votes Please log in or register to add a comment.