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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 2 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option D — 1 5
Detailed Academic Explanation:
1 5 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 3 of 40
★ FPSC
★ PPSC
★ 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"); }
Correct Answer: Option A — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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"); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following structure declaration doesn't require pass-by-reference?
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “Which of the following structure declaration doesn't require pass-by-reference”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many bytes in memory taken by the following C structure? #include <stdio.h> struct test { int k; char c; };
Correct Answer: Option A — Multiple of integer size
Detailed Academic Explanation:
Multiple of integer size is the correct answer to “How many bytes in memory taken by the following C structure? #include <stdio.h> struct test { int k; char c; };”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 6 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — 1
Detailed Academic Explanation:
1 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 7 of 40
★ FPSC
★ PPSC
★ 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]); }
Correct Answer: Option C — this
Detailed Academic Explanation:
this is the correct answer to “What will be the output of the following C code? #include <stdio.h> void main() { char *a[3] = {"hello", "this"}; printf("%s", a[1]); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 8 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — alan
Detailed Academic Explanation:
alan is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax to declare a function foo() which receives an array of structure in function?
Correct Answer: Option A — void foo(struct *var)
Detailed Academic Explanation:
void foo(struct *var) is the correct answer to “What is the correct syntax to declare a function foo() which receives an array of structure in function”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 10 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — Segmentation fault
Detailed Academic Explanation:
Segmentation fault is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 11 of 40
★ FPSC
★ PPSC
★ 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]); }
Correct Answer: Option B — Segmentation fault/code crash
Detailed Academic Explanation:
Segmentation fault/code crash is the correct answer to “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]); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 12 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — 97
Detailed Academic Explanation:
97 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 13 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option D — st st
Detailed Academic Explanation:
st st is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 14 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 15 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option C — 1 somegarbagevalue
Detailed Academic Explanation:
1 somegarbagevalue is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 16 of 40
★ FPSC
★ PPSC
★ 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]); }
Correct Answer: Option A — her
Detailed Academic Explanation:
her is the correct answer to “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]); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 17 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 18 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option B — 10 10
Detailed Academic Explanation:
10 10 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 19 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option D — xyz
Detailed Academic Explanation:
xyz is the correct answer to “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; }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 20 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option A — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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; }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 21 of 40
★ FPSC
★ PPSC
★ 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]; . .
Correct Answer: Option D — Both *symtab[i].u.sval & symtab[i].u.sval[0].
Detailed Academic Explanation:
Both *symtab[i].u.sval & symtab[i].u.sval[0]. is the correct answer to “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]; . .”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 22 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option A — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 23 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option C — hello
Detailed Academic Explanation:
hello is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 24 of 40
★ FPSC
★ PPSC
★ 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)); }
Correct Answer: Option C — 8
Detailed Academic Explanation:
8 is the correct answer to “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)); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is typedef declaration?
Correct Answer: Option C — Does not create a new type, It merely adds a new name for some existing type
Detailed Academic Explanation:
Does not create a new type, It merely adds a new name for some existing type is the correct answer to “What is typedef declaration”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an incorrect syntax for pointer to structure? (Assuming struct temp{int b;}*my_struct;)
Correct Answer: Option A — *my_struct.b = 10
Detailed Academic Explanation:
*my_struct.b = 10 is the correct answer to “Which of the following is an incorrect syntax for pointer to structure? (Assuming struct temp{int b;}*my_struct;)”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The size of a union is determined by the size of the . . . . . . . .
Correct Answer: Option C — Biggest member in the union
Detailed Academic Explanation:
Biggest member in the union is the correct answer to “The size of a union is determined by the size of the . . . . . . . .”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 28 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option A — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not possible regarding the structure variable?
Correct Answer: Option D — None of the mentioned
Detailed Academic Explanation:
None of the mentioned is the correct answer to “Which of the following is not possible regarding the structure variable”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 30 of 40
★ FPSC
★ PPSC
★ 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)); }
Correct Answer: Option B — 12
Detailed Academic Explanation:
12 is the correct answer to “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)); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 31 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option D — 1
Detailed Academic Explanation:
1 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 32 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option B — 1
Detailed Academic Explanation:
1 is the correct answer to “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; }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator connects the structure name to its member name?
Correct Answer: Option C — .
Detailed Academic Explanation:
. is the correct answer to “Which operator connects the structure name to its member name”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following may create problem in the typedef program?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which of the following may create problem in the typedef program”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 35 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option A — 1
Detailed Academic Explanation:
1 is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 36 of 40
★ FPSC
★ PPSC
★ 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; }
Correct Answer: Option B — Output will be 10
Detailed Academic Explanation:
Output will be 10 is the correct answer to “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; }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 37 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option A — alan alan alan turing
Detailed Academic Explanation:
alan alan alan turing is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 38 of 40
★ FPSC
★ PPSC
★ 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); }
Correct Answer: Option A — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “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); }”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which algorithm is used for searching in the table?
Correct Answer: Option C — Hash search
Detailed Academic Explanation:
Hash search is the correct answer to “Which algorithm is used for searching in the table”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax to initialize bit-fields in an structure?
Correct Answer: Option A — struct temp { unsigned int a : 1; }s
Detailed Academic Explanation:
struct temp { unsigned int a : 1; }s is the correct answer to “What is the correct syntax to initialize bit-fields in an structure”. This question is standard in competitive examination syllabi for Structure And Union.
💡Key Conceptual Anchor:Structure And Union
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.