Structure & Union Questions and Answers

Practice Mode
Showing 10 of 95 questions
Q11
How to access eid in the following structure? struct employee { int eid; char name[23]; float salary; } emp={278,"p.das", 5000.000}, *p=&emp; I.  *p->eid II.  p.eid III.  (*p).eid IV..  (*p)->eid
  • A Only I
  • B Only III
  • C Both I & III
  • D All of these
Answer: Option B
Q12
Find the bug in the following jprogram 1. int a=15; 2. struct independence{ 3. int *p; 4. char mon [10]; 5. int year; 6. }data={&a "august", 1947}, *p=&date; 7. void main ( ) { 8. ++*p; 9.printf("%d", *p->q; 10. }
  • A Line no.8
  • B Line no. 9
  • C Line no.6
  • D None
Answer: Option A
Q13
Find the bug in the program 1. typedef struct { 2. char *name; 3. int ano; 4. float bal; 5. }record; 6. void main ( ) { 7. void change (record *p); 8. static record     emp={"abc", 111, 3000.000}; 9. change (emp); 10. void change (record *p) { 11. p->name="xyz", p->ano=222,p-> ball=6000.000; 12. return;}
  • A Line no.1
  • B Line no.7
  • C Line no.9
  • D Line no. 8
Answer: Option C
Q14
State the true statement.
  • A A structure is a value type object.
  • B An empty structure is not allowed in C.
  • C A function can't be a member of a structure
  • D All of the above
Answer: Option D
Q15
Find the output struct dist { char s[8]; char *str; }; void main ( ) { struct dist d={"udaipur", "Jaipur"} printf ("%c%c", d.s[0],++(*d.str)); }
  • A U J
  • B U a
  • C U K
  • D Compilation error
Answer: Option C
Q16
Find the output struct state { char * dname; int dcode; struct state *p; }; void main ( ) { static  struct state q[ ]= {{"Jajpur", 10, q+1}, {"jaipur", 20, q+2}, {"dimapur", 30,q}}; printf ("%s %s", q[0].dname,q[2].p->name);}
  • A Jajpur jaipur
  • B Jajpur dimapur
  • C Jaipur dimapur
  • D Jajpur Jajpur
Answer: Option D
Q17
Find the output. void main ( ) { struct nm { int roll [5]; char aneme[10]; }; printf("5d", sizeof(nm)); }
  • A 20
  • B 21
  • C 10
  • D Compilation error
Answer: Option D
Q18
Self referential structure
  • A Used to create a memory link
  • B Plays an important role in linked list creation.
  • C Contains the object of same structure which is of pointer type..
  • D All the above
Answer: Option D
Q19
Find the incorrect one regarding passing structure to a function,
  • A Supplying structure variable as the arguments in the function call
  • B Providing name of the structure as the function argument in function call.
  • C Providing pointers to the structure variable as the function arguments.
  • D None of these
Answer: Option B
Q20
Choose the correct one
  • A A structure can be nested withing same structure
  • B A value of one structure variable can be assigned to another structure variable of same of different type
  • C The entire structure can't be passed as a function argument.
  • D In self-referential structure one member must be a pointer type
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test