Structure & Union Questions and Answers
Structure & Union Questions with Answers are key topics in C programming questions and answers sections of competitive exams and technical interviews. These concepts allow efficient memory usage and data management, making them essential for understanding advanced C applications. Commonly featured in TCS, Infosys, and Tech Mahindra placement tests, questions on structure and union test your ability to differentiate between memory allocation, member access, and implementation. Practicing C programming MCQs with explanations improves conceptual clarity and debugging skills. Start your preparation with our curated C Structure & Union MCQs and download free PDFs for revision.
Structure & Union
Showing 10 of
95 questions
11. 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
- Only I
- Only III
- Both I & III
- All of these
12. 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. }
- Line no.8
- Line no. 9
- Line no.6
- None
13. 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;}
- Line no.1
- Line no.7
- Line no.9
- Line no. 8
14. State the true statement.
- A structure is a value type object.
- An empty structure is not allowed in C.
- A function can't be a member of a structure
- All of the above
15. 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)); }
- U J
- U a
- U K
- Compilation error
16. 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);}
- Jajpur jaipur
- Jajpur dimapur
- Jaipur dimapur
- Jajpur Jajpur
17. Find the output. void main ( ) { struct nm { int roll [5]; char aneme[10]; }; printf("5d", sizeof(nm)); }
- 20
- 21
- 10
- Compilation error
18. Self referential structure
- Used to create a memory link
- Plays an important role in linked list creation.
- Contains the object of same structure which is of pointer type..
- All the above
19. Find the incorrect one regarding passing structure to a function,
- Supplying structure variable as the arguments in the function call
- Providing name of the structure as the function argument in function call.
- Providing pointers to the structure variable as the function arguments.
- None of these
20. Choose the correct one
- A structure can be nested withing same structure
- A value of one structure variable can be assigned to another structure variable of same of different type
- The entire structure can't be passed as a function argument.
- In self-referential structure one member must be a pointer type