Variables And Data Types In C Plus Plus — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Variables And Data Types In C Plus Plus — Part 1 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 represent hexadecimal values in C++?
Correct Answer: Option D — Prefix with 0x
Detailed Academic Explanation:
Computers use different number systems. Decimal (base-10) is what we use every day. Hexadecimal (base-16) is useful for representing colors, memory addresses, and other things. In C++, we use a special prefix to tell the compiler that a number is in hexadecimal. Option A is incorrect because suffixes (things added to the end) aren't used for this purpose in C++. Option B is also wrong. A prefix means something that comes at the beginning. Option C is close, but not quite right. It's a bit of an older style. Option D, "Prefix with 0x", is the correct answer. The '0x' prefix tells the compiler that the following number is in hexadecimal. For example: 0x1A represents the hexadecimal number 1A, which is equivalent to 26 in decimal. Therefore, the correct way to represent hexadecimal values in C++ is by prefixing them with 0x.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: cout << (5 != 2); in C++?
Correct Answer: Option C — 1
Detailed Academic Explanation:
The output of the code cout << (5 != 2); in C++ will be 1. The expression (5 != 2) is a comparison operation that checks if 5 is not equal to 2. Since 5 is indeed not equal to 2, the expression evaluates to true . In C++, the boolean value true is represented by 1. Therefore, the output will be 1 . However, it seems there might be a misunderstanding. The correct answer should be Option C: 1. If the options provided are fixed, then the answer should be corrected to reflect the boolean output as 1.
💡Key Conceptual Anchor:Variables And Data Types In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct keyword to declare a variable in C++?
Correct Answer: Option C — int
Detailed Academic Explanation:
int is the correct answer to “What is the correct keyword to declare a variable 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 of the following is a valid variable name in C++?
Correct Answer: Option A — myVariable
Detailed Academic Explanation:
myVariable is the correct answer to “Which of the following is a valid variable name 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 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the data type of the variable 'x' in the following declaration: double x = 3.14;?
Correct Answer: Option B — double
Detailed Academic Explanation:
double is the correct answer to “What is the data type of the variable 'x' in the following declaration: double x = 3.14;”. 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
Which of the following is not a primitive data type in C++?
Correct Answer: Option C — string
Detailed Academic Explanation:
string is the correct answer to “Which of the following is not a primitive 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 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the maximum value that can be stored in an 'int' data type in C++?
Correct Answer: Option B — 2147483647
Detailed Academic Explanation:
2147483647 is the correct answer to “What is the maximum value that can be stored in an 'int' 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 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the size of a 'char' data type in C++?
Correct Answer: Option C — 1 byte
Detailed Academic Explanation:
1 byte is the correct answer to “What is the size of a 'char' 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 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following expression in C++: 5 / 2?
Correct Answer: Option D — 2
Detailed Academic Explanation:
2 is the correct answer to “What is the result of the following expression in C++: 5 / 2”. 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
Which operator is used to find the size of a data type in C++?
Correct Answer: Option C — sizeof
Detailed Academic Explanation:
sizeof is the correct answer to “Which operator is used to find the size of a 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 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to declare a constant in C++?
Correct Answer: Option B — const
Detailed Academic Explanation:
const is the correct answer to “What is the correct way to declare a constant 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 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: cout << (true && false); in C++?
Correct Answer: Option B — FALSE
Detailed Academic Explanation:
FALSE is the correct answer to “What will be the output of the following code: cout << (true && false); 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 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax to declare and initialize a variable 'age' of type 'int' with a value of 25 in C++?
Correct Answer: Option C — int age = 25
Detailed Academic Explanation:
int age = 25 is the correct answer to “What is the correct syntax to declare and initialize a variable 'age' of type 'int' with a value of 25 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 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the range of values for a 'short int' data type in C++?
Correct Answer: Option D — -32768 to 32767
Detailed Academic Explanation:
-32768 to 32767 is the correct answer to “What is the range of values for a 'short int' 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 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'auto' keyword do in C++?
Correct Answer: Option A — Declares a variable with an inferred type
Detailed Academic Explanation:
Declares a variable with an inferred type is the correct answer to “What does the 'auto' keyword do 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 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an example of a floating-point data type in C++?
Correct Answer: Option B — float
Detailed Academic Explanation:
float is the correct answer to “Which of the following is an example of a floating-point 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 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct data type for storing a single character in C++?
Correct Answer: Option C — char
Detailed Academic Explanation:
char is the correct answer to “What is the correct data type for storing a single 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 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following code: cout << sizeof(char); in C++?
Correct Answer: Option B — 1
Detailed Academic Explanation:
1 is the correct answer to “What will be the output of the following code: cout << sizeof(char); 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 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a valid way to initialize a variable in C++?
Correct Answer: Option C — int x = 5
Detailed Academic Explanation:
int x = 5 is the correct answer to “Which of the following is a valid way to initialize a variable 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 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the maximum value that can be stored in an 'unsigned int' data type in C++?
Correct Answer: Option D — 4294967295
Detailed Academic Explanation:
4294967295 is the correct answer to “What is the maximum value that can be stored in an 'unsigned int' 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 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the correct way to declare a constant 'PI' with a value of 3.14159 in C++?
Correct Answer: Option D — const double PI = 3.14159
Detailed Academic Explanation:
const double PI = 3.14159 is the correct answer to “Which of the following is the correct way to declare a constant 'PI' with a value of 3.14159 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 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the size of a 'long double' data type in C++?
Correct Answer: Option C — 8 bytes
Detailed Academic Explanation:
8 bytes is the correct answer to “What is the size of a 'long double' 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 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a valid variable name in C++?
Correct Answer: Option D — 123variable
Detailed Academic Explanation:
123variable is the correct answer to “Which of the following is not a valid variable name 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 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to represent octal values in C++?
Correct Answer: Option C — Prefix with 0
Detailed Academic Explanation:
Prefix with 0 is the correct answer to “What is the correct way to represent octal values 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 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'volatile' keyword do in C++?
Correct Answer: Option A — Indicates that a variable may be changed unexpectedly
Detailed Academic Explanation:
Indicates that a variable may be changed unexpectedly is the correct answer to “What does the 'volatile' keyword do 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 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following expression in C++: 7 % 3?
Correct Answer: Option D — 1
Detailed Academic Explanation:
1 is the correct answer to “What is the result of the following expression in C++: 7 % 3”. 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 is the correct way to declare a pointer to an integer in C++?
Correct Answer: Option C — int *ptr
Detailed Academic Explanation:
int *ptr is the correct answer to “What is the correct way to declare a pointer to an integer 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 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the data type of the expression: 5.2f in C++?
Correct Answer: Option B — float
Detailed Academic Explanation:
float is the correct answer to “What is the data type of the expression: 5.2f 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 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: `cout << (true || false);` in C++?
Correct Answer: Option C — TRUE
Detailed Academic Explanation:
TRUE is the correct answer to “What is the output of the following code: `cout << (true || false);` 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 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the range of values for a 'signed char' data type in C++?
Correct Answer: Option A — -128 to 127
Detailed Academic Explanation:
-128 to 127 is the correct answer to “What is the range of values for a 'signed char' 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 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the size of the 'bool' data type in C++?
Correct Answer: Option D — 1 byte
Detailed Academic Explanation:
1 byte is the correct answer to “What is the size of the 'bool' 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 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a valid data type in C++?
Correct Answer: Option D — byte
Detailed Academic Explanation:
byte is the correct answer to “Which of the following is not a valid 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 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the result of the expression: 10 / 3 in C++?
Correct Answer: Option A — 3
Detailed Academic Explanation:
3 is the correct answer to “What will be the result of the expression: 10 / 3 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 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to declare a constant variable named 'PI' with a value of 3.14159 in C++?
Correct Answer: Option D — const double PI = 3.14159
Detailed Academic Explanation:
const double PI = 3.14159 is the correct answer to “What is the correct way to declare a constant variable named 'PI' with a value of 3.14159 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 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the data type of the expression: 3.14f in C++?
Correct Answer: Option B — float
Detailed Academic Explanation:
float is the correct answer to “What is the data type of the expression: 3.14f 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 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the maximum value that can be stored in an 'unsigned short int' data type in C++?
Correct Answer: Option C — 65535
Detailed Academic Explanation:
65535 is the correct answer to “What is the maximum value that can be stored in an 'unsigned short int' 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 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: cout << (7 >= 7); in C++?
Correct Answer: Option A — TRUE
Detailed Academic Explanation:
TRUE is the correct answer to “What is the output of the following code: cout << (7 >= 7); 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 is the data type of the expression: sizeof('A') in C++?
Correct Answer: Option D — int
Detailed Academic Explanation:
int is the correct answer to “What is the data type of the expression: sizeof('A') 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 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: 5.0 + 3 in C++?
Correct Answer: Option C — 8
Detailed Academic Explanation:
8 is the correct answer to “What is the result of the expression: 5.0 + 3 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 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the range of values for an 'unsigned long int' data type in C++?
Correct Answer: Option C — 0 to 4294967295
Detailed Academic Explanation:
0 to 4294967295 is the correct answer to “What is the range of values for an 'unsigned long int' 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
✓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.