Variables And Data Types In C Plus Plus — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Variables And Data Types 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 is the correct way to declare a pointer to a character in C++?
Correct Answer: Option B — char *ptr
Detailed Academic Explanation:
char *ptr is the correct answer to “What is the correct way to declare a pointer to a character in C++”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'volatile' keyword indicate in C++?
Correct Answer: Option C — The value of the variable may change at any time by external factors
Detailed Academic Explanation:
The value of the variable may change at any time by external factors is the correct answer to “What does the 'volatile' keyword indicate in C++”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: cout << (true && true); in C++?
Correct Answer: Option D — TRUE
Detailed Academic Explanation:
TRUE is the correct answer to “What is the output of the following code: cout << (true && true); in C++”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which type is best suited to represent the logical values?
Correct Answer: Option B — boolean
Detailed Academic Explanation:
boolean is the correct answer to “Which type is best suited to represent the logical values”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ function? int main() { register int i = 1; int *ptr = &i; cout << *ptr; return 0; }
Correct Answer: Option C — Compiler error may be possible
Detailed Academic Explanation:
Compiler error may be possible is the correct answer to “What will be the output of the following C++ function? int main() { register int i = 1; int *ptr = &i; cout << *ptr; return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the value of the bool? bool is_int(789.54)
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What is the value of the bool? bool is_int(789.54)”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char c = 74; cout << c; return 0; }
Correct Answer: Option C — J
Detailed Academic Explanation:
J is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char c = 74; cout << c; return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Evaluate the following. (false && true) || false || true
Correct Answer: Option B — 1
Detailed Academic Explanation:
1 is the correct answer to “Evaluate the following. (false && true) || false || true”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The size_t integer type in C++ is?
Correct Answer: Option C — Unsigned integer of at least 16 bits
Detailed Academic Explanation:
Unsigned integer of at least 16 bits is the correct answer to “The size_t integer type in C++ is”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 10 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 = 10; if (a < 10) { for (i = 0; i < 10; i++) cout << i; } else { cout << i; } 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> using namespace std; int main() { int a = 10; if (a < 10) { for (i = 0; i < 10; i++) cout << i; } else { cout << i; } return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens when a null pointer is converted into bool?
Correct Answer: Option C — bool value evaluates to false
Detailed Academic Explanation:
bool value evaluates to false is the correct answer to “What happens when a null pointer is converted into bool”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types 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() { float i = 123.0f; cout << i << endl; return 0; }
Correct Answer: Option C — 123
Detailed Academic Explanation:
123 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { float i = 123.0f; cout << i << endl; return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Pick the odd one out.
Correct Answer: Option A — array type
Detailed Academic Explanation:
array type is the correct answer to “Pick the odd one out.”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many characters are specified in the ASCII scheme?
Correct Answer: Option B — 128
Detailed Academic Explanation:
128 is the correct answer to “How many characters are specified in the ASCII scheme”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the correct option. extern int i; int i;
Correct Answer: Option D — 1 declares i,2 declares and defines i
Detailed Academic Explanation:
1 declares i,2 declares and defines i is the correct answer to “Choose the correct option. extern int i; int i;”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is used to indicate single precision value?
Correct Answer: Option A — F or f
Detailed Academic Explanation:
F or f is the correct answer to “Which is used to indicate single precision value”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
0946, 786427373824, 'x' and 0X2f are . . . . . . . . and . . . . . . . . literals respectively.
Correct Answer: Option D — octal, decimal, character, hexadecimal
Detailed Academic Explanation:
octal, decimal, character, hexadecimal is the correct answer to “0946, 786427373824, 'x' and 0X2f are . . . . . . . . and . . . . . . . . literals respectively.”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In which type do the enumerators are stored by the compiler?
Correct Answer: Option B — integer
Detailed Academic Explanation:
integer is the correct answer to “In which type do the enumerators are stored by the compiler”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The value 132.54 can be represented using which data type?
Correct Answer: Option A — double
Detailed Academic Explanation:
double is the correct answer to “The value 132.54 can be represented using which data type”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the size of wchar_t in C++?
Correct Answer: Option D — Based on the number of bits in the system
Detailed Academic Explanation:
Based on the number of bits in the system is the correct answer to “What is the size of wchar_t in C++”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 21 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 = -1; unsigned int y = 2; if(x > y) { cout << "x is greater"; } else { cout << "y is greater"; } }
Correct Answer: Option A — x is greater
Detailed Academic Explanation:
x is greater is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int x = -1; unsigned int y = 2; if(x > y) { cout << "x is greater"; } else { cout << "y is greater"; } }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; void addprint() { static int s = 1; s++; cout << s; } int main() { addprint(); addprint(); addprint(); return 0; }
Correct Answer: Option A — 234
Detailed Academic Explanation:
234 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; void addprint() { static int s = 1; s++; cout << s; } int main() { addprint(); addprint(); addprint(); return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the value of p in the following C++ code? #include <iostream> using namespace std; int main() { int p; bool a = true; bool b = false; int x = 10; int y = 5; p = ((x | y) + (a + b)); cout << p; return 0; }
Correct Answer: Option B — 16
Detailed Academic Explanation:
16 is the correct answer to “What is the value of p in the following C++ code? #include <iostream> using namespace std; int main() { int p; bool a = true; bool b = false; int x = 10; int y = 5; p = ((x | y) + (a + b)); cout << p; return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int f(int p, int q) { if (p > q) return p; else return q; } main() { int a = 5, b = 10; int k; bool x = true; bool y = f(a, b); k =((a * b) + (x + y)); cout << k; }
Correct Answer: Option C — 52
Detailed Academic Explanation:
52 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int f(int p, int q) { if (p > q) return p; else return q; } main() { int a = 5, b = 10; int k; bool x = true; bool y = f(a, b); k =((a * b) + (x + y)); cout << k; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these expressions will return true if the input integer v is a power of two?
Correct Answer: Option D — (v & (v – 1)) == 0
Detailed Academic Explanation:
(v & (v – 1)) == 0 is the correct answer to “Which of these expressions will return true if the input integer v is a power of two”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What constant defined in <climits> header returns the number of bits in a char?
Correct Answer: Option D — CHAR_BIT
Detailed Academic Explanation:
CHAR_BIT is the correct answer to “What constant defined in <climits> header returns the number of bits in a char”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <stdio.h> int main() { char a = '\012'; printf("%d", a); return 0; }
Correct Answer: Option C — 10
Detailed Academic Explanation:
10 is the correct answer to “What will be the output of the following C++ code? #include <stdio.h> int main() { char a = '\012'; printf("%d", a); return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will happen when defining the enumerated type?
Correct Answer: Option A — it will not allocate memory
Detailed Academic Explanation:
it will not allocate memory is the correct answer to “What will happen when defining the enumerated type”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When a language has the capability to produce new data type mean, it can be called as
Correct Answer: Option B — extensible
Detailed Academic Explanation:
extensible is the correct answer to “When a language has the capability to produce new data type mean, it can be called as”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the given statements are false i. extern int func; ii. extern int func2(int,int); iii. int func2(int,int); iv. extern class foo;
Correct Answer: Option C — only iv
Detailed Academic Explanation:
only iv is the correct answer to “Which of the given statements are false i. extern int func; ii. extern int func2(int,int); iii. int func2(int,int); iv. extern class foo;”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 31 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 = 3; int l = i / -2; int k = i % -2; cout << l << k; return 0; }
Correct Answer: Option B — -1 1
Detailed Academic Explanation:
-1 1 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i = 3; int l = i / -2; int k = i % -2; cout << l << k; return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the following statement mean? void a;
Correct Answer: Option D — flags an error
Detailed Academic Explanation:
flags an error is the correct answer to “What does the following statement mean? void a;”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the value of the following 8-bit integer after all statements are executed? int x = 1; x = x << 7; x = x >> 7;
Correct Answer: Option D — Implementation defined
Detailed Academic Explanation:
Implementation defined is the correct answer to “What is the value of the following 8-bit integer after all statements are executed? int x = 1; x = x << 7; x = x >> 7;”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int num = 0x20 + 020 + 20; cout << sizeof(num)<<'\n'; return 0; }
Correct Answer: Option C — Depends on compiler
Detailed Academic Explanation:
Depends on compiler is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int num = 0x20 + 020 + 20; cout << sizeof(num)<<'\n'; return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following will not return a value?
Correct Answer: Option B — void
Detailed Academic Explanation:
void is the correct answer to “Which of the following will not return a value”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?
Correct Answer: Option B — 1
Detailed Academic Explanation:
1 is the correct answer to “Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Is bool a fundamental data type in C++?
Correct Answer: Option A — Yes
Detailed Academic Explanation:
Yes is the correct answer to “Is bool a fundamental data type in C++”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types 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 a = 8; cout << "ANDing integer 'a' with 'true' :" << (a && true); return 0; }
Correct Answer: Option A — ANDing integer 'a' with 'true' :8
Detailed Academic Explanation:
ANDing integer 'a' with 'true' :8 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 8; cout << "ANDing integer 'a' with 'true' :" << (a && true); return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which data type is used to represent the absence of parameters?
Correct Answer: Option C — void
Detailed Academic Explanation:
void is the correct answer to “Which data type is used to represent the absence of parameters”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { enum channel {star, sony, zee}; enum symbol {hash, star}; int i = 0; for (i = star; i <= zee; i++) { printf("%d ", i); } return 0; }
Correct Answer: Option C — 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> using namespace std; int main() { enum channel {star, sony, zee}; enum symbol {hash, star}; int i = 0; for (i = star; i <= zee; i++) { printf("%d ", i); } return 0; }”. This question is standard in competitive examination syllabi for Variables And Data Types In C Plus Plus.
💡Key Conceptual Anchor:Variables And Data Types 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.