Skip to main content

Structure And Union — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Structure And Union — Part 2 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

What will be the output of the following C code? #include <stdio.h> void main() { struct student { int no; char name[20]; }; struct student s; no = 8; printf("%d", no); }

Question 2 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct p { int x; char y; }; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; struct p *ptr1 = p1; int x = (sizeof(p1) / sizeof(struct p)); printf("%d %d\n", ptr1->x, (ptr1 + x - 1)->x); }

Question 3 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; int main() { struct point p = {1}; struct point p1 = {1}; if(p == p1) printf("equal\n"); else printf("not equal\n"); }

Question 4 of 40
★ FPSC ★ PPSC

Which of the following structure declaration doesn't require pass-by-reference?

Question 5 of 40
★ FPSC ★ PPSC

How many bytes in memory taken by the following C structure? #include <stdio.h> struct test { int k; char c; };

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> typedef struct p { int x, y; }k; int main() { struct p p = {1, 2}; k k1 = p; printf("%d\n", k1.x); }

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> void main() { char *a[3] = {"hello", "this"}; printf("%s", a[1]); }

Question 8 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; struct student fun(void) { struct student s; s.name = "alan"; return s; } void main() { struct student m = fun(); printf("%s", m.name); }

Question 9 of 40
★ FPSC ★ PPSC

What is the correct syntax to declare a function foo() which receives an array of structure in function?

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *c; }; void main() { struct student *s; s->c = "hello"; printf("%s", s->c); }

Question 11 of 40
★ FPSC ★ PPSC

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

Question 12 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> union p { int x; char y; }k = {.y = 97}; int main() { printf("%d\n", k.y); }

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; void main() { struct student s, m; s.name = "st"; m = s; printf("%s%s", s.name, m.name); }

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; struct student s[2], r[2]; void main() { s[0].name = "alan"; s[1] = s[0]; r = s; printf("%s%s", r[0].name, r[1].name); }

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; void foo(struct point*); int main() { struct point p1[] = {1, 2, 3, 4, 5}; foo(p1); } void foo(struct point p[]) { printf("%d %d\n", p->x, p[3].y); }

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> void main() { char *a[3][3] = {{"hey", "hi", "hello"}, {"his", "her", "hell"} , {"hellos", "hi's", "hmm"}}; printf("%s", a[1][1]); }

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> union u { struct { unsigned char x : 2; unsigned int y : 2; }p; int x; }; int main() { union u u = {2}; printf("%d\n", u.p.x); }

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct p { int k; char c; }; int p = 10; int main() { struct p x; x.k = 10; printf("%d %d\n", x.k, p); }

Question 19 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; p.name = "xyz"; p.next = NULL; ptrary[0] = &p; printf("%s\n", ptrary[0]->name); return 0; }

Question 20 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; p->name = "xyz"; p->next = NULL; ptrary[0] = &p; printf("%s\n", p->name); return 0; }

Question 21 of 40
★ FPSC ★ PPSC

In the following C code, we can access the 1st character of the string sval by using . . . . . . #include <stdio.h> struct { char *name; union { char *sval; } u; } symtab[10]; . .

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; struct notpoint { int x; int y; }; int main() { struct point p = {1}; struct notpoint p1 = p; printf("%d\n", p1.x); }

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *c; }; void main() { struct student m; struct student *s = &m; s->c = "hello"; printf("%s", m.c); }

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *c; struct student *point; }; void main() { struct student s; printf("%d", sizeof(s)); }

Question 25 of 40
★ FPSC ★ PPSC

What is typedef declaration?

Question 26 of 40
★ FPSC ★ PPSC

Which of the following is an incorrect syntax for pointer to structure? (Assuming struct temp{int b;}*my_struct;)

Question 27 of 40
★ FPSC ★ PPSC

The size of a union is determined by the size of the . . . . . . . .

Question 28 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct p { int x; char y; }; typedef struct p* q*; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; q ptr1 = p1; printf("%d\n", ptr1->x); }

Question 29 of 40
★ FPSC ★ PPSC

Which of the following is not possible regarding the structure variable?

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? (Assuming size of int be 4) #include <stdio.h> struct temp { int a; int b; int c; } p[] = {0}; main() { printf("%d", sizeof(p)); }

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> union p { int x; char y; }k = {1, 97}; int main() { printf("%d\n", k.y); }

Question 32 of 40
★ FPSC ★ PPSC

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

Question 33 of 40
★ FPSC ★ PPSC

Which operator connects the structure name to its member name?

Question 34 of 40
★ FPSC ★ PPSC

Which of the following may create problem in the typedef program?

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; void foo(struct point*); int main() { struct point p1[] = {1, 2, 3, 4}; foo(p1); } void foo(struct point p[]) { printf("%d\n", p->x); }

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct temp { int a; } s; void change(struct temp); main() { s.a = 10; change(s); printf("%d\n", s.a); } void change(struct temp s) { s.a = 1; }

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; struct student s[2]; void main() { s[0].name = "alan"; s[1] = s[0]; printf("%s%s", s[0].name, s[1].name); s[1].name = "turing"; printf("%s%s", s[0].name, s[1].name); }

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> struct p { int x; char y; }; void foo(struct p* ); int main() { typedef struct p* q; struct p p1[] = {1, 92, 3, 94, 5, 96}; foo(p1); } void foo(struct p* p1) { q ptr1 = p1; printf("%d\n", ptr1->x); }

Question 39 of 40
★ FPSC ★ PPSC

Which algorithm is used for searching in the table?

Question 40 of 40
★ FPSC ★ PPSC

What is the correct syntax to initialize bit-fields in an structure?

✓ 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 →