Skip to main content

Structures And Unions In C Plus Plus MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Structures And Unions In C Plus Plus with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

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

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

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

What is the size of the following structure in C++: struct Employee { int id; char name[20]; float salary; };

Question 2 of 34
★ FPSC ★ PPSC

What is a structure in C++?

Question 3 of 34
★ FPSC ★ PPSC

Which keyword is used to define a structure in C++?

Question 4 of 34
★ FPSC ★ PPSC

What is the correct way to access members of a structure in C++?

Question 5 of 34
★ FPSC ★ PPSC

What is the purpose of typedef in C++ structures?

Question 6 of 34
★ FPSC ★ PPSC

How do you declare a structure variable in C++?

Question 7 of 34
★ FPSC ★ PPSC

What is the output of the following code: struct Student { int roll; }; Student s1; s1.roll = 101; cout << s1.roll; in C++?

Question 8 of 34
★ FPSC ★ PPSC

What is the purpose of using structures in C++?

Question 9 of 34
★ FPSC ★ PPSC

What is the correct way to pass a structure to a function in C++?

Question 10 of 34
★ FPSC ★ PPSC

What is a union in C++?

Question 11 of 34
★ FPSC ★ PPSC

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

Question 12 of 34
★ FPSC ★ PPSC

What is the correct syntax to define a structure pointer in C++?

Question 13 of 34
★ FPSC ★ PPSC

What is the output of the following code: union Data { int x; char y; }; Data d; d.x = 10; d.y = 'A'; cout << d.x << " " << d.y; in C++?

Question 14 of 34
★ FPSC ★ PPSC

What is the purpose of using unions in C++?

Question 15 of 34
★ FPSC ★ PPSC

What does the 'sizeof' operator return when used with a structure in C++?

Question 16 of 34
★ FPSC ★ PPSC

What is the correct syntax to declare a structure with a tag name in C++?

Question 17 of 34
★ FPSC ★ PPSC

What is the correct way to access structure members through a pointer in C++?

Question 18 of 34
★ FPSC ★ PPSC

What is the difference between a structure and a class in C++?

Question 19 of 34
★ FPSC ★ PPSC

What is the output of the following code: struct Point { int x, y; }; Point p1; p1.x = 10; p1.y = 20; cout << p1.x << " " << p1.y; in C++?

Question 20 of 34
★ FPSC ★ PPSC

What is the purpose of the 'typedef' keyword in C++ structures?

Question 21 of 34
★ FPSC ★ PPSC

Which keyword is used to declare a union in C++?

Question 22 of 34
★ FPSC ★ PPSC

What is the correct syntax to define a union in C++?

Question 23 of 34
★ FPSC ★ PPSC

What is the output of the following code: struct Book { char title[50]; int pages; }; Book b; cout << sizeof(b); in C++?

Question 24 of 34
★ FPSC ★ PPSC

What is the output of the following code: union Number { int x; float y; }; Number n; n.x = 10; cout << n.y; in C++?

Question 25 of 34
★ FPSC ★ PPSC

The declaration of the structure is also called as?

Question 26 of 34
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; struct sec { int a; char b; }; int main() { struct sec s ={25,50}; struct sec *ps =(struct sec *)&s; cout << ps->a << ps->b; return 0; }

Question 27 of 34
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; struct Time { int hours; int minutes; int seconds; }; int toSeconds(Time now); int main() { Time t; t.hours = 5; t.minutes = 30; t.seconds = 45; cout << "Total seconds: " << toSeconds(t) << endl; return 0; } int toSeconds(Time now) { return 3600 * now.hours + 60 * now.minutes + now.seconds; }

Question 28 of 34
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> #include <string.h> using namespace std; int main() { struct student { int num; char name[25]; }; student stu; stu.num = 123; strcpy(stu.name, "John"); cout << stu.num << endl; cout << stu.name << endl; return 0; }

Question 29 of 34
★ FPSC ★ PPSC

What will be used when terminating a structure?

Question 30 of 34
★ FPSC ★ PPSC

The data elements in the structure are also known as what?

Question 31 of 34
★ FPSC ★ PPSC

Which of the following is a properly defined structure?

Question 32 of 34
★ FPSC ★ PPSC

What will happen when the structure is declared?

Question 33 of 34
★ FPSC ★ PPSC

What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { struct ShoeType { string style; double price; }; ShoeType shoe1, shoe2; shoe1.style = "Adidas"; shoe1.price = 9.99; cout << shoe1.style << " $ "<< shoe1.price; shoe2 = shoe1; shoe2.price = shoe2.price / 9; cout << shoe2.style << " $ "<< shoe2.price; return 0; }

Question 34 of 34
★ FPSC ★ PPSC

Which of the following accesses a variable in structure *b?

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