Pointers And References In C Plus Plus — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Pointers And References In C Plus Plus — 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 <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = a; cout<<p<<endl; cout<<q<<endl; return 0; }
Correct Answer: Option A — Address of a followed by 5 in next line
Detailed Academic Explanation:
Address of a followed by 5 in next line is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = a; cout<<p<<endl; cout<<q<<endl; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How to declare a wide character in the string literal?
Correct Answer: Option A — L prefix
Detailed Academic Explanation:
L prefix is the correct answer to “How to declare a wide character in the string literal”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Pick the correct statement about references.
Correct Answer: Option B — References once assigned cannot be changed to refer another variable
Detailed Academic Explanation:
References once assigned cannot be changed to refer another variable is the correct answer to “Pick the correct statement about references.”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int numbers[5]; int * p; p = numbers; *p = 10; p++; *p = 20; p = &numbers[2]; *p = 30; p = numbers + 3; *p = 40; p = numbers; *(p + 4) = 50; for (int n = 0; n < 5; n++) cout << numbers[n] << ","; return 0; }
Correct Answer: Option A — 10,20,30,40,50,
Detailed Academic Explanation:
10,20,30,40,50, is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int numbers[5]; int * p; p = numbers; *p = 10; p++; *p = 20; p = &numbers[2]; *p = 30; p = numbers + 3; *p = 40; p = numbers; *(p + 4) = 50; for (int n = 0; n < 5; n++) cout << numbers[n] << ","; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(const int &a) { int temp = 10; a = temp; cout<<a; } int main(int argc, char const *argv[]) { int a = 5; func(a); return 0; }
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; void func(const int &a) { int temp = 10; a = temp; cout<<a; } int main(int argc, char const *argv[]) { int a = 5; func(a); return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i; char c; void *data; i = 2; c = 'd'; data = &i; cout << "the data points to the integer value" << data; data = &c; cout << "the data now points to the character" << data; return 0; }
Correct Answer: Option B — two memory addresses
Detailed Academic Explanation:
two memory addresses is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i; char c; void *data; i = 2; c = 'd'; data = &i; cout << "the data points to the integer value" << data; data = &c; cout << "the data now points to the character" << data; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Regarding the following statement which of the statements is true? const int a = 100;
Correct Answer: Option C — Declares a constant a whose value will be 100
Detailed Academic Explanation:
Declares a constant a whose value will be 100 is the correct answer to “Regarding the following statement which of the statements is true? const int a = 100;”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char *ptr; char Str[] = "abcdefg"; ptr = Str; ptr += 5; cout << ptr; return 0; }
Correct Answer: Option A — fg
Detailed Academic Explanation:
fg is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char *ptr; char Str[] = "abcdefg"; ptr = Str; ptr += 5; cout << ptr; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int &q = a; cout<<&a<<endl; cout<<&q<<endl; return 0; }
Correct Answer: Option D — Address of a followed by Address of a in next line
Detailed Academic Explanation:
Address of a followed by Address of a in next line is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int &q = a; cout<<&a<<endl; cout<<&q<<endl; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The pointer can point to any variable that is not declared with which of these?
Correct Answer: Option C — both const & volatile
Detailed Academic Explanation:
both const & volatile is the correct answer to “The pointer can point to any variable that is not declared with which of these”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; void swap(int &a, int &b); int main() { int a = 5, b = 10; swap(a, b); cout << "In main " << a << b; return 0; } void swap(int &a, int &b) { int temp; temp = a; a = b; b = temp; cout << "In swap " << a << b; }
Correct Answer: Option A — In swap 105 In main 105
Detailed Academic Explanation:
In swap 105 In main 105 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; void swap(int &a, int &b); int main() { int a = 5, b = 10; swap(a, b); cout << "In main " << a << b; return 0; } void swap(int &a, int &b) { int temp; temp = a; a = b; b = temp; cout << "In swap " << a << b; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int *arr[ ] = {&a, &b, &c}; cout << arr[1]; return 0; }
Correct Answer: Option D — it will return some random number
Detailed Academic Explanation:
it will return some random number is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int *arr[ ] = {&a, &b, &c}; cout << arr[1]; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include<iostream> using namespace std; int main() { int x = 10; int& ref = x; ref = 20; cout << x << endl ; x = 30; cout << ref << endl; return 0; }
Correct Answer: Option A — 20 30
Detailed Academic Explanation:
20 30 is the correct answer to “What will be the output of the following C++ code? #include<iostream> using namespace std; int main() { int x = 10; int& ref = x; ref = 20; cout << x << endl ; x = 30; cout << ref << endl; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}; cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]; return 0; }
Correct Answer: Option B — 21 21 21
Detailed Academic Explanation:
21 21 21 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}; cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i; const char *arr[] = {"C", "C++", "Java", "VBA"}; const char *(*ptr)[4] = &arr; cout << ++(*ptr)[2]; return 0; }
Correct Answer: Option A — ava
Detailed Academic Explanation:
ava is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i; const char *arr[] = {"C", "C++", "Java", "VBA"}; const char *(*ptr)[4] = &arr; cout << ++(*ptr)[2]; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Pick the correct statement about references in C++.
Correct Answer: Option B — References and variables both have the same address
Detailed Academic Explanation:
References and variables both have the same address is the correct answer to “Pick the correct statement about references in C++.”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A void pointer cannot point to which of these?
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “A void pointer cannot point to which of these”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Identify the correct sentence regarding inequality between reference and pointer.
Correct Answer: Option A — we can not create the array of reference
Detailed Academic Explanation:
we can not create the array of reference is the correct answer to “Identify the correct sentence regarding inequality between reference and pointer.”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is illegal?
Correct Answer: Option C — int i; double* dp = &i
Detailed Academic Explanation:
int i; double* dp = &i is the correct answer to “Which of the following is illegal”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int *(&q) = p; cout<<q; return 0; }
Correct Answer: Option B — Address of pointer a
Detailed Academic Explanation:
Address of pointer a is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int *(&q) = p; cout<<q; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is not a possible state for a pointer.
Correct Answer: Option D — point to a type
Detailed Academic Explanation:
point to a type is the correct answer to “Which one of the following is not a possible state for a pointer.”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which value can we not assign to reference?
Correct Answer: Option D — null
Detailed Academic Explanation:
null is the correct answer to “Which value can we not assign to reference”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int f(int &x, int c) { c = c - 1; if (c == 0) return 1; x = x + 1; return f(x, c) * x; } int main(int argc, char const *argv[]) { int a = 4; cout<<f(a,a); return 0; }
Correct Answer: Option A — 343
Detailed Academic Explanation:
343 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int f(int &x, int c) { c = c - 1; if (c == 0) return 1; x = x + 1; return f(x, c) * x; } int main(int argc, char const *argv[]) { int a = 4; cout<<f(a,a); return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int &q = NULL; cout<<q; return 0; }
Correct Answer: Option D — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int &q = NULL; cout<<q; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which reference modifier is used to define the reference variable?
Correct Answer: Option A — &
Detailed Academic Explanation:
& is the correct answer to “Which reference modifier is used to define the reference variable”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The operator used for dereferencing or indirection is . . . . . . . .
Correct Answer: Option A — *
Detailed Academic Explanation:
* is the correct answer to “The operator used for dereferencing or indirection is . . . . . . . .”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int &q = 5; cout<<q; return 0; }
Correct Answer: Option D — 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 <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int &q = 5; cout<<q; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When does the void pointer can be dereferenced?
Correct Answer: Option B — when it cast to another type of object
Detailed Academic Explanation:
when it cast to another type of object is the correct answer to “When does the void pointer can be dereferenced”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The constants are also called as . . . . . . . .
Correct Answer: Option C — literals
Detailed Academic Explanation:
literals is the correct answer to “The constants are also called as . . . . . . . .”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *arr + 9; return 0; }
Correct Answer: Option C — 13
Detailed Academic Explanation:
13 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *arr + 9; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int &p; int a = 5; &p = a; cout<<p; return 0; }
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int &p; int a = 5; &p = a; cout<<p; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char arr[20]; int i; for(i = 0; i < 10; i++) *(arr + i) = 65 + i; *(arr + i) = '\0'; cout << arr; return(0); }
Correct Answer: Option A — ABCDEFGHIJ
Detailed Academic Explanation:
ABCDEFGHIJ is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char arr[20]; int i; for(i = 0; i < 10; i++) *(arr + i) = 65 + i; *(arr + i) = '\0'; cout << arr; return(0); }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the parts of the literal constants?
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
all of the mentioned is the correct answer to “What are the parts of the literal constants”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the meaning of the following declaration? int(*p[5])();
Correct Answer: Option B — p is array of pointer to function
Detailed Academic Explanation:
p is array of pointer to function is the correct answer to “What is the meaning of the following declaration? int(*p[5])();”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will happen in the following C++ code snippet? int a = 100, b = 200; int *p = &a, *q = &b; p = q;
Correct Answer: Option B — p now points to b
Detailed Academic Explanation:
p now points to b is the correct answer to “What will happen in the following C++ code snippet? int a = 100, b = 200; int *p = &a, *q = &b; p = q;”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; #define PI 3.14159 int main () { float r = 2; float circle; circle = 2 * PI * r; cout << circle; return 0; }
Correct Answer: Option A — 12.5664
Detailed Academic Explanation:
12.5664 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; #define PI 3.14159 int main () { float r = 2; float circle; circle = 2 * PI * r; cout << circle; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the difference between references and pointers?
Correct Answer: Option A — References are an alias for a variable whereas pointer stores the address of a variable
Detailed Academic Explanation:
References are an alias for a variable whereas pointer stores the address of a variable is the correct answer to “What is the difference between references and pointers”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int *p; void *vp; if (vp == p) cout << "equal"; return 0; }
Correct Answer: Option A — equal
Detailed Academic Explanation:
equal is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int *p; void *vp; if (vp == p) cout << "equal"; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include<iostream> using namespace std; int &fun() { static int x = 10; return x; } int main() { fun() = 30; cout << fun(); return 0; }
Correct Answer: Option A — 30
Detailed Academic Explanation:
30 is the correct answer to “What will be the output of the following C++ code? #include<iostream> using namespace std; int &fun() { static int x = 10; return x; } int main() { fun() = 30; cout << fun(); return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = p; cout<<p; return 0; }
Correct Answer: Option D — 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 <iostream> #include <string> #include <cstdlib> using namespace std; int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = p; cout<<p; return 0; }”. This question is standard in competitive examination syllabi for Pointers And References In C Plus Plus.
💡Key Conceptual Anchor:Pointers And References In C Plus Plus
✓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.