Introduction to C++: book back answers

18 solved questions from the end of this chapter, Class 11 Computer Science, Tamil Nadu State Board. Each answer is checked against the textbook, and you can open the page that proves it.

← Notes and quiz for Introduction to C++

SECTION – A Choose the correct answer

  1. Who developed C++?

    • (a) Charles Babbage
    • (b) Bjarne Stroustrup
    • (c) Bill Gates
    • (d) Sundar Pichai
    Try it, then show the answer

    (b) Bjarne Stroustrup

    The chapter identifies Bjarne Stroustrup as the developer of C++.

    From the book: “C++ was developed by Bjarne Stroustrup at AT & T Bell Laboratory during 1979.”

  2. What was the original name given to C++?

    • (a) CPP
    • (b) Advanced C
    • (c) C with Classes
    • (d) Class with C
    Try it, then show the answer

    (c) C with Classes

    Stroustrup initially named the language “C with Classes”.

    From the book: “Bjarne Stroustrup named his new language as “C with Classes”.”

  3. Who coined C++?

    • (a) Rick Mascitti
    • (b) Rick Bjarne
    • (c) Bill Gates
    • (d) Dennis Ritchie
    Try it, then show the answer

    (a) Rick Mascitti

    The chapter says Rick Mascitti coined the name C++.

    From the book: “The name C++ was coined by Rick Mascitti”

  4. The smallest individual unit in a program is:

    • (a) Program
    • (b) Algorithm
    • (c) Flowchart
    • (d) Tokens
    Try it, then show the answer

    (d) Tokens

    The smallest individual unit in a program is called a token or lexical unit.

    From the book: “The smallest individual unit in a program is known as a Token or a Lexical unit”

  5. Which of the following operator is extraction operator in C++?

    • (a) >>
    • (b) <<
    • (c) <>
    • (d) ^^
    Try it, then show the answer

    (a) >>

    The >> operator extracts input and is called the stream extraction operator.

    From the book: “C++ provides the operator >> to get input.”

  6. Which of the following statements is not true?

    • (a) Keywords are the reserved words which convey specific meaning to the C++ compiler.
    • (b) Reserved words or keywords can be used as an identifier name.
    • (c) An integer constant must have at least one digit without a decimal point.
    • (d) Exponent form of real constants consist of two parts
    Try it, then show the answer

    (b) Reserved words or keywords can be used as an identifier name.

    Keywords cannot be used as identifier names, so this statement is not true.

    From the book: “Reserved words or keywords cannot be used as an identifier name.”

  7. Which of the following is a valid string literal?

    • (a) ‘A’
    • (b) ‘Welcome’
    • (c) 1232
    • (d) “1232”
    Try it, then show the answer

    (d) “1232”

    A string literal is a sequence of characters enclosed within double quotes.

    From the book: “Sequence of characters enclosed within double quotes are called as String literals.”

  8. A program written in high level language is called as

    • (a) Object code
    • (b) Source code
    • (c) Executable code
    • (d) All the above
    Try it, then show the answer

    (b) Source code

    The chapter calls the typed C++ program source code. The other terms refer to later forms produced during compilation and execution.

    From the book: “Creating includes typing and editing the valid C++ code”

  9. Which of the following is called as compile time operators?

    • (a) sizeof
    • (b) pointer
    • (c) virtual
    • (d) this
    Try it, then show the answer

    (a) sizeof

    The chapter identifies sizeof as a compile time operator.

    From the book: “This is called as compile time operator. It returns the size of a variable in bytes.”

SECTION-B

  1. What is meant by a token? Name the token available in C++.

    Try it, then show the answer

    A token is the smallest individual unit in a program. C++ tokens are keywords, identifiers, literals, operators and punctuators.

    The chapter defines tokens as individual program elements and lists five categories.

    From the book: “C++ has the following tokens: • Keywords • Identifiers • Literals • Operators • Punctuators”

  2. What are keywords? Can keywords be used as identifiers?

    Try it, then show the answer

    Keywords are reserved words that convey specific meaning to the C++ compiler. No, keywords cannot be used as identifiers.

    Keywords have a reserved meaning in C++, and the chapter explicitly disallows using them as identifier names.

    From the book: “Reserved words or keywords cannot be used as an identifier name.”

  3. Describe the differences between keywords and identifiers?

    Try it, then show the answer

    Keywords are reserved words with specific meanings to the C++ compiler. Identifiers are user-defined names for parts of a program, such as variables, functions, arrays and classes.

    Keywords are part of the language's reserved vocabulary; identifiers are names supplied by the programmer and must follow naming rules.

    From the book: “Identifiers are the user-defined names given to different parts of the C++ program”

  4. Is C++ case sensitive? What is meant by the term “case sensitive”?

    Try it, then show the answer

    Yes. Case sensitive means that C++ treats uppercase and lowercase characters differently.

    For example, the chapter lists Num and NUM as separate valid identifiers, reflecting the difference in letter case.

    From the book: “C++ is case sensitive as it treats upper and lower-case characters differently.”

  5. Differentiate “=” and “==”.

    Try it, then show the answer

    = is the assignment operator; it copies the value on its right to the variable on its left. == is a relational operator used to compare two operands for equality.

    Assignment stores a value, while equality comparison tests a relationship between operands and yields a Boolean result.

    From the book: “This operator copies the value at the right side of the operator to the left side variable.”

  6. What is the use of a header file?

    Try it, then show the answer

    A header file provides definitions needed by a program. The iostream header file provides the definitions of cin and cout for input and output.

    Including iostream lets a program use the standard input and output objects cin and cout.

    From the book: “iostream header file contains the definition of its member objects cin and cout.”

  7. Why is main function special?

    Try it, then show the answer

    The main() function is the starting point where a C++ program begins execution. Executable statements should be inside it.

    Every C++ program must have a main function, which begins the program's execution.

    From the book: “The main( ) function is the starting point where all C++ programs begin their execution.”

Explain in detail

  1. Write about Binary operators used in C++.

    Try it, then show the answer

    Binary operators require two operands. In C++, they are classified as arithmetic, relational, logical, assignment and conditional operators.

    1. Arithmetic operators: They perform arithmetic operations such as addition, subtraction, multiplication, division and finding the remainder.
    2. Relational operators: They compare two operands. The result is a Boolean value: 1 for true or 0 for false.
    3. Logical operators: AND and OR combine logical expressions. AND returns true when both expressions are true; OR returns true when either expression is true.
    4. Assignment operators: The assignment operator copies the value on the right to the variable on the left. Shorthand assignment operators include +=, -=, *=, /= and %=.
    5. Conditional operator: The conditional operator ?: is used as an alternative to the if…else control statement.

    Example: 10 % 3 = 1 (Remainder of the division)

    Thus, C++ binary operators perform operations using two operands.

    From the book: “(ii) Binary Operators - Require two operands”

  2. What are the types of Errors?

    Try it, then show the answer

    Errors are mistakes in a program that may be detected when the source code is compiled or executed. The chapter describes syntax errors and gives an example of one.

    1. Syntax errors: Syntax errors occur when the grammatical rules of C++ are violated.
    2. Cause: Each programming language has its own rules for constructing source code. Breaking those rules causes a syntax error.
    3. Compiler message: When a mistake or error is found during compilation, the compiler displays an error message.
    4. Example: The example statement is missing the required semicolon at its end, so it violates C++ grammatical rules.

    Example: cout << “Welcome to Programming in C++”

    The chapter identifies syntax errors as mistakes caused by violating C++ grammatical rules.

    From the book: “A run time error occurs during the execution of a program.”

Next chapterFlow of Control