Arrays and Structures: book back answers

16 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 Arrays and Structures

SECTION – A — Choose the correct answer

  1. Which of the following is the collection of variables of the same type that an referenced by a common name ?

    • a) int
    • b) float
    • c) Array
    • d) class
    Try it, then show the answer

    c) Array

    An array is a collection of same-type variables referenced by a common name.

    From the book: “An array is a collection of variables of the same type that are referenced by a common name”

  2. int age[]={6,90,20,18,2}; How many elements are there in this array?

    • a) 2
    • b) 5
    • c) 6
    • d) 4
    Try it, then show the answer

    b) 5

    The initialized list contains five values, so the array has five elements.

    From the book: “the size is determined by compiler which depends on the total number of values.”

  3. cin>>n[3]; To which element does this statement accept the value?

    • a) 2
    • b) 3
    • c) 4
    • d) 5
    Try it, then show the answer

    c) 4

    Array subscripts start at 0, so subscript 3 refers to the fourth element.

    From the book: “num[3] refers to the 4th element in the array.”

  4. Structure definition is terminated by

    • (a) :
    • (b) }
    • (c) ;
    • (d) ::
    Try it, then show the answer

    (c) ;

    A structure definition ends with a semicolon after its closing brace.

    From the book: “struct Student long rollno; int age; float weight; } ;”

  5. A structure declaration is given below. struct Time { int hours; int minutes; int seconds; }t; Using above declaration which of the following refers to seconds.

    • (a) Time.seconds
    • (b) Time::seconds
    • (c)seconds
    • (d) t. seconds
    Try it, then show the answer

    (d) t. seconds

    Structure members are accessed by writing the structure object name, a dot, and the member name.

    From the book: “using a dot (.) between the object name and the member name.”

  6. Which of the following is a properly defined structure?

    • (a) struct {int num;}
    • (b) struct sum {int num;}
    • (c) struct sum int sum;
    • (d)struct sum {int num;};
    Try it, then show the answer

    (d)struct sum {int num;};

    A named structure definition has the struct keyword, a name, braces containing members, and a terminating semicolon.

    From the book: “struct structure_name { type member_name1; type member_name2; } reference_name;”

  7. A structure declaration is given below. struct employee { int empno; char ename[10]; }e[5]; Using above declaration which of the following statement is correct.

    • (a) cout<<e[0].empno<<e[0].ename;
    • (b) cout<<e[0].empno<<ename;
    • (c)cout<<e[0]->empno<<e[0]->ename;
    • (d) cout<<e.empno<<e.ename;
    Try it, then show the answer

    (a) cout<<e[0].empno<<e[0].ename;

    e is an array of structures, so e[0] selects a structure object and the dot operator accesses its members.

    From the book: “The syntax for that is using a dot (.) between the object name and the member name.”

  8. When accessing a structure member ,the identifier to the left of the dot operator is the name of

    • (a) structure variable
    • (b) structure tag
    • (c) structure member
    • (d) structure function
    Try it, then show the answer

    (a) structure variable

    The dot is placed between the object name and the member name.

    From the book: “using a dot (.) between the object name and the member name.”

SECTION-B

  1. What is Traversal in an Array?

    Try it, then show the answer

    Traversal is the process of going through the array elements, typically using a loop to access or compare each element.

    The chapter describes processing array elements successively through a loop, including traversing and comparing all elements during a search.

    From the book: “until all the elements in the array have been traversed and compared.”

  2. What is Strings?

    Try it, then show the answer

    A string is a sequence of characters, where each character may be a letter, number or symbol, and the string ends with a null character.

    C++ represents a string as a one-dimensional character array terminated by '\0'.

    From the book: “A string is defined as a sequence of characters where each character may be a letter, number or a symbol.”

  3. What is the syntax to declare two – dimensional array.

    Try it, then show the answer

    data-type array_name[row-size][col-size];

    The declaration gives the data type, array name, row size and column size.

    From the book: “The declaration of a 2-D array is data-type array_name[row-size][col-size];”

  4. Define structure .What is its use?

    Try it, then show the answer

    A structure is a user-defined type that groups data items of different data types into one unit. It is used to store different types of related data together as one logical element.

    Unlike an array, a structure can contain members with different data types.

    From the book: “This allows to group variables of mixed data types together into a single unit.”

  5. Define an Array ? What are the types?

    Try it, then show the answer

    An array is a collection of variables of the same type referenced by a common name. The types are one-dimensional arrays, two-dimensional arrays and multi-dimensional arrays.

    The chapter defines arrays by their common name and same-type elements, then lists these three array types.

    From the book: “There are different types of arrays used in C++. They are: • One-dimensional arrays • Two-dimensional arrays • Multi-dimensional arrays”

  6. Write note an Array of strings.

    Try it, then show the answer

    An array of strings is a two-dimensional character array. Its first index gives the number of strings, and its second index gives the maximum length of each string. Space is allowed for the null character at the end of each string.

    Each row stores one string and each row must accommodate its terminating null character.

    From the book: “An array of strings is a two-dimensional character array.”

  7. How to access members of a structure?Give example.

    Try it, then show the answer

    Access a structure member using the structure object name, a dot operator, and then the member name. For example: balu.age

    The dot operator joins the object name to the requested member name.

    From the book: “balu.rollno balu.age balu.weight frank.rollno frank.age frank.weight”

  8. What is called anonymous structure .Give an example

    Try it, then show the answer

    A structure without a name or tag is called an anonymous structure. Example: struct { long rollno; int age; float weight; } student;

    The example has no structure tag; the declared object name is student.

    From the book: “A structure without a name/tag is called anonymous structure.”

Next chapterIntroduction to Object Oriented Programming Techniques