Variables and Data Types in C++

    Last Updated :
    Discuss
    Comments

    Question 1

    Which of the following is a valid variable name in C++?

    • 3var

    • var_name

    • int

    • float#

    Question 2

    What is the size of an int in C++ compilers?

    • 2 bytes

    • 4 bytes

    • 8 bytes

    • Compiler dependent

    Question 3

    Which keyword is used in C++ to declare a variable that cannot be changed?

    • constant

    • const

    • final

    • immutable

    Question 4

    What data type should be used to store a single character?

    • string

    • char

    • int

    • bool

    Question 5

    Which of the following is NOT a primitive data type in C++?

    • double

    • class

    • bool

    • char

    Question 6

    Which type modifier can be used to store only positive integers?

    • Unsiged

    • signed

    • volatile

    • const

    Question 7

    Which data type is used to store true or false values?

    • int

    • char

    • bool

    • float

    Question 8

    What will be the output of the following code?

    C++
    int main() {
        bool a = true;
        bool b = false;
        int c = a + b + 10;
        cout << c;
    }
    


    • 10

    • 11

    • true

    • Error: Cannot add boolean and integer.

    Question 9

    Which type qualifier is used to tell the compiler that a variable’s value may change unexpectedly?

    • const

    • static

    • volatile

    • mutable

    Question 10

    What type of data does std::string hold?

    • characters

    • floating point numbers

    • integers

    • Boolean Values

    Tags:

    There are 21 questions to complete.

    Take a part in the ongoing discussion