551 views
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

1 Answer

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

Related questions

0 votes
0 votes
0 answers
1
Anirudh Kaushal asked Apr 6, 2022
191 views
#include<stdio.h struct marks { int p:3; int c:3; int m:2; }; void main() { struct marks s = {2, -6, 5}; printf("%d %d %d", s.p, s.c, s.m); }What does p:3 means here ?
0 votes
0 votes
1 answer
2
Parshu gate asked Nov 19, 2017
359 views
#include<stdio.h>int main(){ int a=2;if(a==2){ a=~a+2<<1; printf("%d",a);}}
2 votes
2 votes
2 answers
3
Parshu gate asked Nov 5, 2017
1,293 views
OPTIONSA)7,19 B) 10,1 C) 10,23 D)10,32
1 votes
1 votes
1 answer
4
Archies09 asked Apr 23, 2017
3,179 views
What will be the output of the program?#include<stdio.h int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4...