C++ Data Types MCQs: 12 Fundamental and Derived Type Questions Solved
Test C++ data-type fundamentals through concise traces of conversions, declarations, pointers, and references, then use the error map to target revision.
KnowledgeGate Team
Exam prep & CS education

C++ data-type questions go beyond naming int, bool, or char. They combine case-sensitive keywords, representation assumptions, Boolean conversion, pointer declarations, precedence, and reference aliasing. Choose an option before reading each explanation.
Question-specific pages are unavailable, so each answer opens the C++ Data Types lesson for concept review after your attempt.
C++ data types: build the map before solving
![C++ type-family map with array, pointer, reference aliasing, and marks[1] changing from 72 to 75.](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1793295842027_17q518.jpg)
Family | Exact examples | What the MCQs test |
|---|---|---|
fundamental |
| valid keywords, values, size assumptions, conversion |
derived | array, pointer, reference | declaration binding, address changes, aliasing |
qualifier in this set |
| whether a value may be changed through a name or pointer |
user-defined direction |
| why C++ is extensible |
Use bool ready = true;, int marks[3] = {64, 72, 81};, int *ptr = &marks[1];, and int &alias = marks[1];. Initially, *ptr and alias read 72; after alias = 75, marks[1], *ptr, and alias read 75. Array, pointer, and reference are derived; const is a qualifier, not a fundamental type.
For Question 4, C++ guarantees sizeof(char) == 1, but int and float byte sizes are implementation-dependent. The stated 8-bit-byte, 4-byte int, and 4-byte float model makes 1, 4, 4 valid here, not universally.
C++ Data Types MCQs 1-3: valid types, bool, and wide characters
Question 1 (IBPS 2025)
Which of the following is not a valid data type in the C++ programming language?
A. Float
B. Int
C. Real
D. Char
E. Double
C++ has the fundamental keywords float, int, char, and double, but no standard built-in keyword real. The answer is C under the question's intended interpretation. The wording has a flaw: C++ is case-sensitive, making the capitalised spellings non-keywords too unless separately declared. Treat those spellings here as labels for the lowercase types.
Question 2 (DSSSB 2021)
In C++, bool data type is used to hold how many values?
A. n²
B. 2
C. 2n
D. 2ⁿ
A bool represents only false and true. Integer conversion maps them to 0 and 1, but adds no Boolean values. The expressions n², 2n, and 2ⁿ vary with n. The stem asks for a fixed cardinality, which is exactly 2 logical values in this type.
Question 3 (DSSSB 2021)
In C++ a wide-character constant begins with the letter _____.
A. W
B. C
C. L
D. S
'A' is a character literal; L'A' is a wide-character literal. Uppercase L sits before the opening quote, making C correct. W, C, and S are distractors. This syntax does not give wchar_t a fixed byte width across implementations.
C++ Data Types MCQs 4-6: size, round-off, and Boolean conversion
Question 4 (TCS 2024)
What will be the output of the following C++ code, assuming 8-bit bytes, a 4-byte int, and a 4-byte float?
#include<iostream>
using namespace std;
int main()
{
cout << sizeof(char) << " ";
cout << sizeof(int) << " ";
cout << sizeof(float);
return 0;
}A. 1 4 4
B. 1 4 8
C. 1 8 8
D. 1 8 2
Under the stated model, sizeof(char) = 1, sizeof(int) = 4, and sizeof(float) = 4, producing 1 4 4. Only the char result is universally fixed at one C++ byte; the question explicitly supplies the int and float sizes.
Question 5 (Indian Space Research Organization 2008)
Repeated execution of simple computation may cause compounding of
A. round-off errors
B. syntax errors
C. run-time errors
D. logic errors
Correct answer: A. round-off errors.
Ten additions give 10 × 0.1 = 1.0 mathematically. Binary floating-point may store 0.1 approximately, so repetition can accumulate round-off error. Syntax, run-time, and logic errors are different fault classes; they do not compound in this numerical sense.
Question 6 (BPSC 2023)
What is the value of ‘p’ in the following C++ code snippet?
#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;
}A. 12
B. 16
C. 2
D. More than one of the above
E. None of the above
Because x = 10 and y = 5 are non-zero, (x || y) is true, contributing integer 1. Next, a + b becomes 1 + 0 = 1. Thus p = 1 + 1 = 2. The magnitudes 10 and 5 are not directly added.
C++ Data Types MCQs 7-8: const and declaration compatibility
Question 7 (MPPSC 2025)
In C++, using const keyword we can declare
A. "I promise not to change this value"
B. "I promise to change this value"
C. "I promise to double this value"
D. "I promise to exchange this value with other value"
Correct answer: A. "I promise not to change this value".
With const int limit = 25;, assignment limit = 30; is not allowed through that name. Option A summarises this no-modification contract. The keyword qualifies a type; it neither creates a fundamental type nor promises doubling or exchange.
Question 8 (DSSSB 2018)
Which of the following is not a correct declaration statement in C++?
A.
int *ptr=0, p;B.
int p, *ptr = 0;C.
int p; double *fp = &p;D.
int *p, *q, r;
Correct answer: C. int p; double *fp = &p;.
In A and B, ptr is an int* and p an int. In D, p and q are int*, while r is an int. In C, &p is an int*, which cannot initialise a double*; these types are incompatible.
C++ Data Types MCQs 9-10: pointer assignment and precedence
Question 9 (DSSSB 2018)
Consider the following C++ code segment:
int a = 10, b = 20;
int *p = &a, *q = &b;
p = q;With respect to the code segment mentioned above, which of the following statement is correct?
A. Both a and b will contain 10
B. Both a and b will contain 20
C. Both p and q will point to a
D. Both p and q will point to b
Correct answer: D. Both p and q will point to b.
Place a = 10 at 0x1000 and b = 20 at 0x2000. Initially, p stores 0x1000 and q stores 0x2000. Assignment p = q copies 0x2000 into p without changing either integer. Both pointers then designate b; a remains 10 and b remains 20 unchanged.
Question 10 (RSSB 2022, Computer Science, BCI-Paper2)
*ptrdatais a pointer to a data type.The expression
*ptrdata++is evaluated as (C++) –
A.
*(ptrdata++)B.
(*ptrdata)++C.
*(ptrdata)+D. Depends on compiler
Correct answer: A. *(ptrdata++).
Postfix ++ binds before unary *, so the parse is *(ptrdata++). Let ptrdata point to 7 at 0x1000, followed by 9 at 0x1004. The expression yields 7, then advances the pointer to 0x1004. It does not increment stored value 7, which would require (*ptrdata)++ instead.
C++ Data Types MCQs 11-12: pointer-to-pointer and reference traces
Question 11 (TCS 2026)
Predict the output of the following program:
#include<iostream>
using namespace std;
int main()
{
const char* p = "12345";
const char **q = &p;
*q = "abcde";
const char *s = ++p;
p = "XYZWVU";
cout << *++s;
return 0;
}A. Compiler Error
B. c
C. b
D. Garbage Value
Because q points to p, *q = "abcde" redirects p to a. Then s = ++p advances p to b and copies that address to s. Redirecting p to "XYZWVU" leaves s unchanged. Finally, ++s advances from b to c, which is printed by the program.
Question 12 (TCS 2024)

Output of following C++ program?
#include <iostream>
using namespace std;
int main()
{
int x = 10;
int& ref = x;
ref = 20;
cout << "x = " << x << endl ;
x = 30;
cout << "ref = " << ref << endl;
return 0;
}A.
x = 20
ref = 30B.
x = 20
ref = 20C.
x = 10
ref = 30D.
x = 30
ref = 30Correct answer: A. x = 20, then ref = 30.
A reference is an alias, not a copy. int& ref = x binds both names to one int. Thus ref = 20 changes x from 10 to 20, producing the first line. Then x = 30 changes the same object, so reading ref produces 30 on the second line.
C++ data types: diagnose the misses and choose the next step
Misses on Questions 1 to 3 call for reviewing fundamental types and literal syntax. For Questions 4 to 6, practise assumptions and conversions. For Questions 7 or 8, rewrite declarations one variable per line. For Questions 9 to 12, trace addresses and aliases first.
Redo all 12 tomorrow in 12 minutes: allow 2 minutes each for Questions 11 and 12, and 8 minutes for the other ten. Follow C++ Programming for a dedicated language sequence, Coding For Placements for a multi-language path, or browse Coding & Skills. Compare the type system with Data Types and Operators in C, then use C Programming MCQs if you also need C declaration practice.
Keep learning
Templates in C++: Reusable Parameterized Code with Worked Examples
Learn how one C++ template produces type-specific functions and classes. Follow exact calls, calculations, deduction failures, and practical corrections.
Friend Functions in C++: Controlled Class Access with a Worked Example
See how a non-member friend function can validate and update two Wallet objects while private balances stay hidden from ordinary callers. Includes runnable C++ and an exact trace.
Data Types in C++: Fundamental and Derived Types with Worked Examples
Learn how C++ fundamental types differ from arrays, pointers, references, and function types. Trace one complete program, then test the conversion traps.
C++ Constructors and Object Initialization: Techniques, Order and a Worked Trace
Learn how C++ chooses default, parameterised, delegating and copy constructors, then trace member states and initialization order through complete code.





