Skip to main content

Structure And Union — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Structure And Union — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

Find the output of the following program: void main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d", s->x); printf("%s", s->name); }

Question 2 of 40
★ FPSC ★ PPSC

Consider the following code. struct account{ int acno; }svar, *pv = &svar; then the acno can be accessed by

Question 3 of 40
★ FPSC ★ PPSC

Consider the following declarations: union id { char color; int size; }; struct{ char country; int date; union id id; }flag; To assign a color to a flag, the correct statement would be

Question 4 of 40
★ FPSC ★ PPSC

For the following structure declaration, find the correct statement. struct person{ char name[20]; int age; struct person lady; };

Question 5 of 40
★ FPSC ★ PPSC

The restriction with union is

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct p { char *name; struct p *next; }; struct p *ptrary[10]; int main() { struct p p, q; p.name = "xyz"; p.next = NULL; ptrary[0] = &p; strcpy(q.name, p.name); ptrary[1] = &q; printf("%s\n", ptrary[1]->name); return 0; }

Question 7 of 40
★ FPSC ★ PPSC

What is the keyword used to define a structure in C?

Question 8 of 40
★ FPSC ★ PPSC

In a structure, what are the members also known as?

Question 9 of 40
★ FPSC ★ PPSC

Which of the following can be a member of a structure?

Question 10 of 40
★ FPSC ★ PPSC

How do you access a member of a structure in C?

Question 11 of 40
★ FPSC ★ PPSC

What is the primary difference between a structure and a union in C?

Question 12 of 40
★ FPSC ★ PPSC

How is the size of a structure determined in C?

Question 13 of 40
★ FPSC ★ PPSC

Which statement correctly defines a structure named "Person" with members "name" and "age" of type char* and int respectively?

Question 14 of 40
★ FPSC ★ PPSC

What does the 'sizeof' operator in C return for a union?

Question 15 of 40
★ FPSC ★ PPSC

Can a structure have another structure as a member in C?

Question 16 of 40
★ FPSC ★ PPSC

Which operator is used to access a union member when the union is a part of a structure?

Question 17 of 40
★ FPSC ★ PPSC

What happens when you assign a value to one member of a union and then access another member in C?

Question 18 of 40
★ FPSC ★ PPSC

Which keyword is used to define an anonymous structure or union within another structure or union?

Question 19 of 40
★ FPSC ★ PPSC

In a union, which member can you access safely after assigning a value to one of its members?

Question 20 of 40
★ FPSC ★ PPSC

Which type of variable should you use if you want to store different types of data at different times within the same memory location?

Question 21 of 40
★ FPSC ★ PPSC

Which of the following is true about the memory allocation of structures and unions in C?

Question 22 of 40
★ FPSC ★ PPSC

In C, can a structure be passed as an argument to a function?

Question 23 of 40
★ FPSC ★ PPSC

What is the purpose of using a typedef with structures and unions in C?

Question 24 of 40
★ FPSC ★ PPSC

When should you use a structure instead of an array in C?

Question 25 of 40
★ FPSC ★ PPSC

What is the purpose of an anonymous union in C?

Question 26 of 40
★ FPSC ★ PPSC

Which keyword is used to access a member of a nested structure in C?

Question 27 of 40
★ FPSC ★ PPSC

What is the main advantage of using a union in C?

Question 28 of 40
★ FPSC ★ PPSC

What is the size of an empty structure in C?

Question 29 of 40
★ FPSC ★ PPSC

In C, can you compare two structures using the equality operator (==)?

Question 30 of 40
★ FPSC ★ PPSC

What is the primary use of a union in a C program?

Question 31 of 40
★ FPSC ★ PPSC

How do you declare an array of structures in C?

Question 32 of 40
★ FPSC ★ PPSC

Which of the following is not a valid type for a structure member in C?

Question 33 of 40
★ FPSC ★ PPSC

In C, can you have a structure as a member of itself (a recursive structure)?

Question 34 of 40
★ FPSC ★ PPSC

What is the purpose of the offsetof macro in C?

Question 35 of 40
★ FPSC ★ PPSC

Which keyword is used to create a new name for an existing data type in C?

Question 36 of 40
★ FPSC ★ PPSC

How many union members can be initialized?

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int main() { typedef struct p *q; struct p { int x; char y; q ptr; }; struct p p = {1, 2, &p}; printf("%d\n", p.ptr->x); return 0; }

Question 38 of 40
★ FPSC ★ PPSC

Can the following C code be compiled successfully? #include <stdio.h> struct p { int k; char c; float f; }; int main() { struct p x = {.c = 97, .f = 3, .k = 1}; printf("%f\n", x.f); }

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int *(*(x()))[2]; typedef int **(*ptrfoo)())[2]; int main() { ptrfoo ptr1; ptr1 = x; ptr1(); return 0; } int *(*(x()))[2] { int (*ary)[2] = malloc(sizeof * ary); return &ary; }

Question 40 of 40
★ FPSC ★ PPSC

Which of the following share a similarity in syntax? 1. Union, 2. Structure, 3. Arrays and 4. Pointers

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →