Structure & Union Questions and Answers

Practice Mode
Showing 10 of 95 questions
Q21
State the true statement.
  • A The structure elements are always arranged in contiguous memory locations.
  • B A structure can be read as a single entity
  • C A structure can be a member with in it.
  • D None of these
Answer: Option C
Q22
Find the output. typedef struct bitfield { int a:3; char b:7; unsigned int c:12; }bit; void main ( ) { bit b1; printf"%d", sizeof(b1)); }
  • A 22
  • B 5
  • C 3
  • D 2
Answer: Option C
Q23
Find the output. struct bits { unsigned int a:3; }; void main ( ) { struct bits b={8}' printf ("5d", b.a); }
  • A 8
  • B 3
  • C 0
  • D None of these
Answer: Option C
Q24
Find the output struct student { char nm[10]; int roll; }; void main ( ) { struct student *s,p={raja", 5}' s=&p; printf("%d %s", *s.nm,*s.roll); }
  • A raja 5
  • B Garbage garbage
  • C Non portable pointers conversion
  • D Compilation error
Answer: Option D
Q25
Structure is used for
  • A Data encapsulation
  • B Create memory link
  • C Bit fields
  • D All of the above
Answer: Option D
Q26
All structure variables are created in
  • A Code area
  • B Stack area
  • C Data area
  • D Depends on storage class
Answer: Option D
Q27
Find the output struct st { char *name; int age; int (*p) ( ); }; void main ( ) { struct st s={"raja", 10}; s.p=show (&s); } show (struct st *s) { printf('%s", ++s->name); }
  • A Raja
  • B aja
  • C Pointer to function can't be a part of structure
  • D None of these
Answer: Option B
Q28
Can members of a union be same as that of structure member if union is nested withing that structure ?
  • A yes
  • B No
  • C Can't say
  • D Gives runtime error
Answer: Option A
Q29
Find the output struct x { char *x; }; void main ( ) { struct x x={"rama"}; printf("%s", x.x); }
  • A rama
  • B Compilation error
  • C Runtime error
  • D None of these
Answer: Option A
Q30
Find the output struct main { int n; int (*p) ( ); }; void main ( ) { struct main m; int fun( ); m.p=fun; * (m.p) ( ); } fun ( ) { printf("Hello"); }
  • A Hello
  • B Hello Hello
  • C No output
  • D Compilation error
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test