Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers

Official Kerala Board Solutions for Class 11 Computer Science: Chapter 08 Arrays

Review structured textbook solutions for Class 11 Computer Science Chapter 08 Arrays. Built according to Kerala Board guidelines for the 2026-27 academic year, these downloadable answers support daily revision and problem-solving accuracy.

Chapter-wise Solutions for Computer Science: Chapter 08 Arrays

Navigate directly to the solved Computer Science textbook exercises using the digital viewer below. Each solution includes detailed step-by-step explanations, allowing students to instantly cross-check their work and identify areas requiring further revision.

One Mark Questions and Answers

Question 1: From the following, which is not true for an array?
a) It is easy to represent and manipulate array variables
b) Array uses a compact memory structure
c) Readability of the program is increased
d) Array elements are dissimilar elements

Answer:

d) Array elements are dissimilar elements. All the elements of an array must be of the same data type.

Exam Tips:

a) An array holds elements of one data type only; this is the most common one-mark point in this chapter.

 

Question 2: Consider the declaration int mark(50). Is it valid? If not, give the correct declaration.

Answer:

It is not valid. The correct declaration is int mark[50];. Square brackets must be used instead of parentheses.

Exam Tips:

a) The size of an array is always written inside square brackets [ ], never ( ) or { }.

 

Question 3: Consider the declaration int mark[200];. The index of the last element is ________.

Answer:

199

Exam Tips:

a) The last index is always size - 1, so for 200 elements it is 199.

 

Question 4: Consider the declaration int mark[200];. The index of the first element is ________.

Answer:

0

Exam Tips:

a) Array indexing in C++ starts from 0, not 1.

 

Question 5: Consider int age[4] = {15, 16, 17, 18};. Which type of initialisation is this?
a) direct assignment
b) along with variable declaration
c) multiple assignment
d) None of these

Answer:

b) along with variable declaration

Exam Tips:

a) Values given in braces at the time of declaration is initialisation along with declaration.

 

Question 6: Which of the following is used to read and display array elements?
a) loops
b) if
c) switch
d) if else ladder

Answer:

a) loops

Exam Tips:

a) Loops (usually for loops) visit every element, so they are used to read and display arrays.

 

Question 7: Write down the memory consumption in bytes of each of the following.
1. int age[10]
2. char name[10]
3. int age[10][10]

Answer:

1. 2 × 10 = 20 bytes (taking 2 bytes for one integer)
2. 1 × 10 = 10 bytes (one byte for each character)
3. 2 × 10 × 10 = 200 bytes (2 bytes × 100 elements)

Exam Tips:

a) Memory = size of one element × number of elements. In a 2D array the number of elements is rows × columns.
b) The textbook takes 2 bytes per int here; modern compilers use 4 bytes (see the answer to the later question on int AR[10]). Always follow the value given in the question.

 

Question 8: A two dimensional array has ________ number of subscripts.
a) one
b) two
c) three
d) none of these

Answer:

b) two

Exam Tips:

a) A two dimensional array needs two subscripts: one for the row and one for the column.

 

Question 9: Consider int age[10][10];. How many elements does this array contain?

Answer:

10 × 10 = 100 elements

Exam Tips:

a) Number of elements of a 2D array = number of rows × number of columns.

 

Question 10: Consider int age[4] = {12, 13, 14}; and the statement cout<<age[3];. What will be the output?
a) 14
b) 12
c) 13
d) 0

Answer:

d) 0. The array has four elements, and the one not given a value (age[3]) is automatically set to 0.

Exam Tips:

a) When fewer values than the size are given in the initialiser, the remaining elements become 0.

 

Question 11: The elements of a two dimensional array can be read using a ________ loop.

Answer:

Nested loop

Exam Tips:

a) Use one loop for rows and another loop inside it for columns.

 

Question 12: ________ is the process of reading or visiting the elements of an array.

Answer:

Traversal

Exam Tips:

a) Traversal means visiting every element once, for example to display it or to find the total.

 

Question 13: Anjali wants to read the 10 marks already stored in an array and find their total. This process is known as ________.
a) insertion
b) deletion
c) traversal
d) linear search

Answer:

c) traversal

Exam Tips:

a) Visiting every element (reading, adding or printing) is traversal.

 

Question 14: Mani wants to check a number among 100 numbers already stored in an array. This process is called ________.
a) insertion
b) deletion
c) searching
d) None of these

Answer:

c) searching

Exam Tips:

a) Finding the position of a given element in an array is searching.

 

Question 15: The divide and conquer method is used in ________ search.

Answer:

Binary

Exam Tips:

a) Binary search repeatedly halves the array, which is the divide and conquer idea.

 

Question 16: "Each element of the array is compared with the value to be searched, starting from the beginning of the array." This method is used by ________ search.

Answer:

Linear search

Exam Tips:

a) Linear search is also called sequential search; it checks elements one by one from the first.

 

Question 17: ________ search requires a sorted array as input.

Answer:

Binary search

Exam Tips:

a) Binary search works only if the array is already sorted.

 

Question 18: ________ searching is slower for larger arrays.

Answer:

Linear searching

Exam Tips:

a) Linear search may have to check every element, so its time grows with the size of the array.

 

Question 19: ________ is a simple sorting algorithm.
a) bubble sort
b) selection sort
c) linear search
d) binary search

Answer:

a) bubble sort

Exam Tips:

a) Linear search and binary search are searching methods, not sorting methods.

 

Question 20: Adjacent elements are compared and interchanged in ________ sort.

Answer:

Bubble sort

Exam Tips:

a) Remember: bubble sort compares neighbouring elements and swaps them if they are out of order.

 

Question 21: The array is divided into a sorted part and an unsorted part in ________ sort.

Answer:

Selection sort

Exam Tips:

a) Selection sort repeatedly picks the smallest (or largest) element from the unsorted part and places it in the sorted part.

 

Question 22: The elements of an array of size ten are numbered from ________ to ________.

Answer:

0 to 9

Exam Tips:

a) Indices run from 0 to size - 1.

 

Question 23: The element mark[6] is which element of the array?
a) the sixth
b) the seventh
c) the eighth
d) impossible to tell

Answer:

b) the seventh. Since the index starts from 0, mark[6] is the seventh element.

Exam Tips:

a) Element number = index + 1.

 

Question 24: When a multidimensional array is accessed, each array index is ________.
a) separated by column
b) surrounded by brackets and separated by commas
c) separated by commas and surrounded by brackets
d) surrounded by brackets

Answer:

d) surrounded by brackets. Each index is written in its own pair of square brackets, as in mat[1][2].

Exam Tips:

a) Never use commas between indices in C++; write mat[i][j], not mat[i,j].

 

Question 25: You have used a 2D array named mat representing a matrix. Write the C++ expression to access the 3rd element in the 2nd row.

Answer:

mat[1][2]

Exam Tips:

a) Row index 2 - 1 = 1 and column index 3 - 1 = 2, because indexing starts at 0.

 

Question 26: Write a C++ statement that defines a string variable called name that can hold a string of up to 20 characters.

Answer:

char name[21];. One extra location is needed for the null character (\0) that ends the string.

Exam Tips:

a) A string of n characters needs an array of size n + 1 because of the null character.

 

Question 27: Given some array declarations, pick the odd man out.
float a[+40], int num[0-10], double [50], char name[50], amount[20] of float

Answer:

char name[50] is the odd one out. It is a valid array declaration, and all the others are invalid.

Exam Tips:

a) A valid declaration has a data type, a name and a positive constant size in square brackets.

 

Question 28: ________ is a collection of elements of the same data type.

Answer:

Array

Exam Tips:

a) An array stores many values of the same type under one name.

 

Question 29: int num[10];
The above C++ statement declares an array named num that can store a maximum of ________ integer numbers. (September 2015)
a) 9
b) 10
c) N
d) none of these

Answer:

b) 10

Exam Tips:

a) The number in the brackets is the number of elements; the indices are 0 to 9.

 

Question 30: Declare a two dimensional array to store the elements of a matrix of order 3 × 5. (March 2016)

Answer:

int m[3][5]; (or float m[3][5];)

Exam Tips:

a) The first subscript is the number of rows (3) and the second is the number of columns (5).

 

Question 31: ________ search method is an example of the divide and conquer method. (September 2016)

Answer:

Binary

Exam Tips:

a) Binary search compares with the middle element and discards half of the array each time.

 

Question 32: Read the following C++ statement: int AR[10];
How many bytes will be allocated for this array?

Answer:

An integer needs 4 bytes, so AR[10] needs 10 × 4 = 40 bytes.

Exam Tips:

a) Bytes = number of elements × bytes per element; here 4 bytes is taken for an int.

 

Question 33: Find the value of score[4] based on the following declaration. (March 2017)
int score[5] = {98, 87, 92, 79, 85};

Answer:

85. The index starts from 0, so score[4] is the fifth (last) element of the array.

Exam Tips:

a) score[0] = 98, score[1] = 87, score[2] = 92, score[3] = 79 and score[4] = 85.

 

Two Mark Questions and Answers

Question 34: Is the statement char text[] = "COMPUTER"; True or False? Justify.

Answer:

The statement is true (it is valid). It declares a single dimensional character array. If the size is not specified, the compiler allocates the number of characters plus one location for the null character. Here "COMPUTER" has 8 characters, so 9 bytes of memory are allocated.

Exam Tips:

a) Always add 1 for the null character when you count the size of a string.
b) Say clearly that the array has no size given, so the size is taken from the initial string.

 

Question 35: Given the word "Mathematics", how will you locate this word in a standard dictionary? What are the steps used for this purpose?

Answer:

The words in a standard dictionary are arranged in sorted order, so the binary search method is the most suitable way to find the word "MATHEMATICS".

Steps:
1. Open the dictionary at the middle page and compare the word there with "MATHEMATICS".
2. If it matches, the search is over.
3. If the word comes after the required word in alphabetical order, repeat the process in the first half; otherwise repeat it in the second half.
4. Continue until the word is found.

Exam Tips:

a) Mention that sorted data is the reason for choosing binary search.
b) Write the steps in order and use the words "middle", "first half" and "second half".

 

Question 36: How can you find the word "MATHEMATICS" in a textbook? Which is the most convenient method? Justify your answer.

Answer:

The words in a textbook are not arranged in sorted order, so the linear search method is the convenient one. We check the words one by one from the beginning until the word is found.

Exam Tips:

a) Unsorted data means linear search; sorted data means binary search.

 

Question 37: Consider the statement char str[] = "PROGRAM";. What will be stored in the last location of this array? Justify.

Answer:

The last location holds the null character (\0). Every string is terminated by a null character, so the array has 8 locations: P, R, O, G, R, A, M and \0.

Exam Tips:

a) The null character is not displayed but it takes one memory location.

 

Question 38: Explain the different array operations in detail.

Answer:

1. Traversal: visiting every element of the array and processing it.
2. Searching: checking whether a given element is present in the array or not.
3. Sorting: arranging the elements in an order (ascending or descending).

Exam Tips:

a) Write the three operations with a one-line meaning for each.
b) Give a small example such as finding the total of marks for traversal.

 

Question 39: Read the following C++ statement: int MAT[5][4]; (March 2015)
1. How many bytes will be allocated for this array?
2. Suppose MAT[4][4] is a 2D array that contains the elements of a square matrix. Write C++ statements to find the sum of all the elements in the array.

Answer:

1. The array has 5 × 4 = 20 elements. With 4 bytes for each integer, 20 × 4 = 80 bytes are allocated (40 bytes if an integer takes 2 bytes, as in older compilers).

2. Program to find the sum of all the elements of a 4 × 4 matrix:

#include<iostream>
using namespace std;
int main()
{
    int MAT[4][4], i, j, SUM = 0;
    cout<<"Enter 4*4=16 elements for the matrix";
    for(i = 0; i < 4; i++)
        for(j = 0; j < 4; j++)
        {
            cin>>MAT[i][j];
            SUM = SUM + MAT[i][j];
        }
    cout<<"The matrix is given below\n";
    for(i = 0; i < 4; i++)
    {
        for(j = 0; j < 4; j++)
            cout<<MAT[i][j]<<"\t";
        cout<<endl;
    }
    cout<<"The sum of elements is "<<SUM;
}

Exam Tips:

a) Use two nested for loops for a 2D array, and initialise SUM to 0 before the loops.
b) Add each element to SUM inside the inner loop.

 

Question 40: Declare an array of size 5 and initialise it with the numbers 8, 7, 2, 4 and 6. (March 2016)

Answer:

int n[5] = {8, 7, 2, 4, 6};

Exam Tips:

a) The values are written in braces, separated by commas, after the equals sign.

 

Question 41: Predict the output of the following C++ program.

#include<iostream.h>
int main()
{
    int array[] = {1, 2, 4, 6, 7, 5};
    for(int n = 1; n <= 5; n++)
        array[n] = array[n - 1];
    for(n = 0; n <= 5; n++)
        cout<<array[n];
    return 0;
}

Answer:

The first loop copies each element from the one before it: array[1] = array[0] = 1, then array[2] = array[1] = 1, and so on, so every element becomes 1.
The second loop prints all six elements one after another, so the output is 111111 (six 1s).

Exam Tips:

a) Trace the loop step by step: each assignment uses the value that has just been changed.
b) Output from cout without separators is printed as a continuous string of digits.

 

Question 42: Suppose M[5][5] is a 2D array that contains the elements of a square matrix. Write C++ statements to find the sum of the diagonal elements. (SCERT Sample Paper II)

Answer:

S = 0;
for(i = 0; i < 5; i++)
    for(j = 0; j < 5; j++)
        if(i == j)
            S = S + M[i][j];

Exam Tips:

a) Diagonal elements are those where the row index equals the column index (i == j).
b) Initialise the sum S to 0 before the loops.

 

Question 43: 1. Write a C++ program for sorting a list of numbers using the Bubble Sort method.
2. Write the different passes of sorting the following numbers using Bubble Sort: 32, 21, 9, 17, 5

Answer:

1. Bubble sort program (ascending order):

#include<iostream>
using namespace std;
int main()
{
    int i, j, n[5], t;
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter number "<<i + 1<<":";
        cin>>n[i];
    }
    for(i = 0; i < 4; i++)
        for(j = 0; j < 4 - i; j++)
            if(n[j] > n[j + 1])
            {
                t = n[j];
                n[j] = n[j + 1];
                n[j + 1] = t;
            }
    cout<<"The sorted array is given below";
    for(i = 0; i < 5; i++)
        cout<<n[i]<<",";
}

2. Bubble sort (ascending order). In each pass, adjacent elements are compared and interchanged if the first one is greater.
Pass 1: 32 and 21 are interchanged: 21, 32, 9, 17, 5. Then 32 and 9: 21, 9, 32, 17, 5. Then 32 and 17: 21, 9, 17, 32, 5. Then 32 and 5: 21, 9, 17, 5, 32. The largest number 32 is now at the right end.
Pass 2: 21, 9 → 9, 21, 17, 5, 32; 21, 17 → 9, 17, 21, 5, 32; 21, 5 → 9, 17, 5, 21, 32.
Pass 3: 9, 17 stay; 17, 5 → 9, 5, 17, 21, 32.
Pass 4: 9, 5 → 5, 9, 17, 21, 32.
The sorted array is 5, 9, 17, 21, 32.

Exam Tips:

a) For n numbers, bubble sort needs at most n - 1 passes; the largest remaining element moves to the end in each pass.
b) Show the array after each pass; this is how the marks are awarded.
c) In the program the inner loop runs to 4 - i because the last i elements are already in place.

 

Question 44: Suppose M[5][5] is a 2D array that contains the elements of a square matrix. Write C++ statements to find the sum of the diagonal elements. (March 2017)

Answer:

#include<iostream>
using namespace std;
int main()
{
    int mat[5][5], i, j, sum = 0;
    cout<<"Enter 25 elements";
    for(i = 0; i < 5; i++)
        for(j = 0; j < 5; j++)
        {
            cin>>mat[i][j];
            if(i == j)
                sum += mat[i][j];
        }
    cout<<"The matrix is given below\n";
    for(i = 0; i < 5; i++)
    {
        for(j = 0; j < 5; j++)
            cout<<mat[i][j]<<"\t";
        cout<<"\n";
    }
    cout<<"\nThe diagonal sum is "<<sum;
}

Exam Tips:

a) The condition i == j picks the main diagonal; for the other diagonal use i + j == 4 in a 5 × 5 matrix.
b) Keep the sum variable initialised to 0.

 

Three Mark Questions and Answers

Question 45: Suppose you are given the total marks of 50 students in a class.
1. How will you store these values using ordinary variables?
2. Is there any other efficient way to store these values? Give reason.

Answer:

1. We would have to declare 50 variables individually to store the total marks of 50 students. This is laborious work.

2. Yes. We use an array, which is an efficient way to declare 50 variables at once. With a single variable name we can store multiple elements. For example, int mark[50]; can store 50 marks. The first mark is in mark[0], the second in mark[1], and so on, up to the fiftieth mark in mark[49].

Exam Tips:

a) Give the reason clearly: one name, many values, accessed by index.
b) Include the declaration int mark[50]; and mention that the last index is 49.

 

Question 46: Four friends are standing in a queue for watching a movie. How can you locate a particular person in that queue? Write all the steps sequentially.

Answer:

A particular person in the queue can be located in two ways.

1. Linear search: each element of the array is compared with the element to be searched, starting from the first element. When a match is found, the position of the element is returned.

2. Binary search: this uses the divide and conquer technique and can be performed only on a sorted array. First the element to be searched is compared with the middle element. There are three possibilities:
(i) the searched element is the middle element, and then the search is finished;
(ii) the searched element is less than the middle element, so the search continues in the lower half and the upper bound becomes the position before the middle;
(iii) the searched element is greater than the middle element, so the search continues in the upper half and the lower bound becomes the position after the middle.
This process is repeated.

Exam Tips:

a) Name both methods and say when each is used: binary search needs sorted data, linear search does not.
b) Write the steps in order using the words "compare", "middle element", "lower bound" and "upper bound".

 

Question 47: The total marks of 50 students in a class are given in an array. A bonus of 10 marks is awarded to all of them. Write the program code for making such a modification.

Answer:

#include<iostream>
using namespace std;
int main()
{
    int i, mark[50];
    for(i = 0; i < 50; i++)
    {
        cout<<"Enter mark "<<i + 1<<" : ";
        cin>>mark[i];
    }
    cout<<"\nThe mark of 50 students after adding bonus mark 10 is given below \n";
    for(i = 0; i < 50; i++)
        cout<<mark[i] + 10<<endl;
}

Exam Tips:

a) Traverse the array with a for loop; add 10 to each element while printing, or write mark[i] = mark[i] + 10; to change the stored value.
b) The loop runs from 0 to 49 (i < 50).

 

Question 48: In the school assembly, try to arrange all the students of your class in increasing order of their heights, separately for male and female students. The smallest one will be in front and the tallest one at the last position. Write the sequential steps for doing this in two different methods.

Answer:

Arranging elements from smallest to largest (ascending) or from largest to smallest (descending) is called sorting. There are two sorting methods.

1. Bubble sort: this is a simple sorting method. Two adjacent elements are considered and, if they are out of order, they are interchanged. After the first iteration the largest element (in ascending sorting) or the smallest element (in descending sorting) reaches the end of the array. This process continues.

2. Selection sort: the array is divided into two parts, the sorted part and the unsorted part. The smallest element in the unsorted part is searched for and exchanged with the first element of the unsorted part. This process continues until the whole array is sorted.

Exam Tips:

a) Name the two methods first and then explain each in two or three lines.
b) Mention how the array is divided into a sorted and an unsorted part in selection sort.

 

Question 49: Write complete programs for the two types of sorting (bubble sort and selection sort) to arrange 5 numbers in ascending order.

Answer:

Bubble sort:

#include<iostream>
using namespace std;
int main()
{
    int i, j, n[5], t;
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter number "<<i + 1<<":";
        cin>>n[i];
    }
    for(i = 0; i < 4; i++)
        for(j = 0; j < 4 - i; j++)
            if(n[j] > n[j + 1])
            {
                t = n[j];
                n[j] = n[j + 1];
                n[j + 1] = t;
            }
    cout<<"The sorted array is given below";
    for(i = 0; i < 5; i++)
        cout<<n[i]<<",";
}

Selection sort:

#include<iostream>
using namespace std;
int main()
{
    int small, pos, i, j, n[5], t;
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter number "<<i + 1<<":";
        cin>>n[i];
    }
    for(i = 0; i < 5; i++)
    {
        small = n[i];
        pos = i;
        for(j = i + 1; j < 5; j++)
            if(n[j] < small)
            {
                small = n[j];
                pos = j;
            }
        t = n[i];
        n[i] = small;
        n[pos] = t;
    }
    cout<<"The sorted array is given below";
    for(i = 0; i < 5; i++)
        cout<<n[i]<<",";
}

Exam Tips:

a) In bubble sort, the inner loop compares neighbours; in selection sort, the inner loop finds the position of the smallest element.
b) Initialise pos = i in selection sort so that the swap is correct even when the first element is already the smallest.
c) Use a temporary variable t for every swap.

 

Question 50: Collect the heights of 12 students from your class, of whom 7 are male and the others are female. Suppose these male and female students sit on two separate benches and you are given a place where all 12 students can sit in a line. How will you combine them and make them sit without mixing male and female students? Write a program for the same.

Answer:

The heights of the male students are stored in one array (m[7]) and those of the female students in another (f[5]). Each array is sorted by bubble sort and then the elements of m are copied into the combined array mf[12], followed by the elements of f. Male and female students are therefore not mixed.

#include<iostream>
using namespace std;
int main()
{
    int i, j, m[7], f[5], mf[12], t;
    for(i = 0; i < 7; i++)
    {
        cout<<"Enter the height of male student "<<i + 1<<":";
        cin>>m[i];
    }
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter the height of female student "<<i + 1<<":";
        cin>>f[i];
    }
    for(i = 0; i < 6; i++)
        for(j = 0; j < 6 - i; j++)
            if(m[j] > m[j + 1])
            {
                t = m[j];
                m[j] = m[j + 1];
                m[j + 1] = t;
            }
    for(i = 0; i < 4; i++)
        for(j = 0; j < 4 - i; j++)
            if(f[j] > f[j + 1])
            {
                t = f[j];
                f[j] = f[j + 1];
                f[j + 1] = t;
            }
    for(i = 0; i < 7; i++)
        mf[i] = m[i];
    for(j = 0; j < 5; j++)
        mf[i + j] = f[j];
    cout<<"The combined array is given below";
    for(i = 0; i < 12; i++)
        cout<<mf[i]<<",";
}

Exam Tips:

a) Copy the first array into the combined array, then copy the second array starting at index 7 (the value of i after the first loop).
b) Size of the combined array = 7 + 5 = 12.

 

Question 51: Collect the heights of 12 students from your class, of whom 7 are male and the others are female. Suppose you are given the heights in sorted order separately for male and female students. How will you combine these groups in the same order in a line? Write a program for the same.

Answer:

The two sorted arrays are merged into a third array. The first elements of the two arrays are compared and the smaller one is copied to the combined array; then the next elements are compared, and so on. When one array is finished, the remaining elements of the other array are copied. (The program also sorts the entered heights so that it works for any input.)

#include<iostream>
using namespace std;
int main()
{
    int i, j, k, m[7], f[5], mf[12], t;
    for(i = 0; i < 7; i++)
    {
        cout<<"Enter the height of male student "<<i + 1<<":";
        cin>>m[i];
    }
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter the height of female student "<<i + 1<<":";
        cin>>f[i];
    }
    for(i = 0; i < 6; i++)
        for(j = 0; j < 6 - i; j++)
            if(m[j] > m[j + 1])
            {
                t = m[j];
                m[j] = m[j + 1];
                m[j + 1] = t;
            }
    for(i = 0; i < 4; i++)
        for(j = 0; j < 4 - i; j++)
            if(f[j] > f[j + 1])
            {
                t = f[j];
                f[j] = f[j + 1];
                f[j + 1] = t;
            }
    i = j = k = 0;
    while(i < 7 && j < 5)
    {
        if(m[i] < f[j])
        {
            mf[k] = m[i];
            i++;
        }
        else
        {
            mf[k] = f[j];
            j++;
        }
        k++;
    }
    if(i >= 7)
        for(; j < 5; j++, k++)
            mf[k] = f[j];
    else
        for(; i < 7; i++, k++)
            mf[k] = m[i];
    cout<<"The sorted array is given below";
    for(i = 0; i < 12; i++)
        cout<<mf[i]<<",";
}

Exam Tips:

a) Use three index variables: i for the first array, j for the second and k for the combined array.
b) After the while loop one array is exhausted; copy the leftover elements of the other array.

 

Question 52: Write the program code for counting the number of vowels in your school name.

Answer:

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main()
{
    char line[80];
    int i, vowel = 0;
    puts("Enter your school name");
    gets(line);
    for(i = 0; line[i] != '\0'; i++)
        switch(tolower(line[i]))
        {
            case 'a':
            case 'e':
            case 'i':
            case 'o':
            case 'u': vowel++;
        }
    cout<<"The number of vowels in your school name is "<<vowel;
}

Exam Tips:

a) Convert each character to lower case with tolower() so that both capital and small vowels are counted.
b) The loop continues until the null character \0 is reached.

 

Question 53: Write the program code for counting the number of words in the given string "Directorate of Higher Secondary Examination".

Answer:

Words are separated by spaces (ASCII value 32), so the number of words is one more than the number of spaces when there is exactly one space between words.

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int i, words = 1;
    char str[80];
    cout<<"Enter a string\n";
    gets(str);
    for(i = 0; str[i] != '\0'; i++)
        if(str[i] == 32)
            words++;
    cout<<"The number of words is "<<words;
}

Alternative program (it also works when there is more than one space between words):

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
    int i, j, words = 0;
    char str[80];
    cout<<"Enter a string\n";
    gets(str);
    if(str[0] != 32 && str[0] != '\0')
    {
        words = 1;
        i = 1;
        while(str[i] != '\0')
        {
            if(str[i] == 32)
            {
                for(j = i; str[j] == 32; j++)
                    if(str[j + 1] == '\0')
                    {
                        cout<<"The number of words is "<<words;
                        exit(0);
                    }
                words++;
                i = j + 1;
            }
            else
                i++;
        }
    }
    else
    {
        words = 0;
        i = 0;
        while(str[i] != '\0')
        {
            if(str[i] == 32)
            {
                for(j = i; str[j] == 32; j++)
                    if(str[j + 1] == '\0')
                    {
                        cout<<"The number of words is "<<words;
                        exit(0);
                    }
                words++;
                i = j + 1;
            }
            else
                i++;
        }
    }
    cout<<"The number of words is "<<words;
}

Exam Tips:

a) The ASCII value of a space is 32; you may also write str[i] == ' '.
b) The simple program is enough for the given string; the second one handles extra spaces at the start, middle or end.

 

Question 54: Given a word like "ECNALUBMA", write the program code for arranging it into a meaningful word.

Answer:

The letters of "ECNALUBMA" are in reverse order. Reversing the string gives the meaningful word "AMBULANCE".

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int i, len = 0;
    char str[80];
    puts("Enter a string :");
    gets(str);
    for(i = 0; str[i] != 0; i++)
        len++;
    for(i = len - 1; i >= 0; i--)
        putchar(str[i]);
}

Input: ECNALUBMA
Output: AMBULANCE

Exam Tips:

a) First find the length of the string, and then print the characters from the last index (len - 1) down to 0.

 

Question 55: Explain the need for arrays.

Answer:

An array is a collection of elements of the same type. With one name we can store many elements, and the elements are distinguished by their index or subscript. To store the marks of 50 students we would otherwise have to declare 50 variables, which is laborious. By using an array this is very easy: int mark[50];. Here the index of the first element is 0, then 1, 2, 3 and so on up to 49.

Exam Tips:

a) Give an example of declaring 50 values with one statement to support your answer.
b) Mention that the index (subscript) identifies each element.

 

Question 56: Explain the different types of arrays.

Answer:

There are two types of arrays.

1. Single dimensional array: it has only one index or subscript. The index starts from 0 and ends with size - 1.
Examples: int n[50]; and char name[10];

2. Multi-dimensional array: it has more than one index or subscript. A two dimensional array has two indices, one for rows and one for columns. The row index starts from 0 and ends at row size - 1, and the column index starts from 0 and ends at column size - 1.
Example: int n[10][10]; can store 10 × 10 = 100 elements. The index of the first element is n[0][0] and the index of the 100th element is n[9][9].

Exam Tips:

a) Give one example declaration for each type.
b) Mention the index range of each dimension (0 to size - 1).

 

Question 57: Write a program to read 5 marks of a student and display the marks and the total.

Answer:

#include<iostream>
using namespace std;
int main()
{
    int mark[5], i, total = 0;
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter mark "<<i + 1<<":";
        cin>>mark[i];
        total = total + mark[i];
    }
    cout<<"\nThe marks are given below\n";
    for(i = 0; i < 5; i++)
        cout<<mark[i]<<endl;
    cout<<"The total mark is "<<total;
}

Exam Tips:

a) Add each mark to total while reading it, so only one loop is needed for the sum.
b) Initialise total to 0 before the loop.

 

Question 58: Write a program to read 3 marks of each of 5 students, and find and display the total of each student.

Answer:

#include<iostream>
using namespace std;
int main()
{
    int mark[5][3], i, j, total[5];
    for(i = 0; i < 5; i++)
    {
        total[i] = 0;
        cout<<"Enter 3 marks of student "<<i + 1<<endl;
        for(j = 0; j < 3; j++)
        {
            cout<<"Enter mark "<<j + 1<<":";
            cin>>mark[i][j];
            total[i] = total[i] + mark[i][j];
        }
    }
    for(i = 0; i < 5; i++)
    {
        cout<<"\nThe marks of student "<<i + 1<<" are given below\n";
        for(j = 0; j < 3; j++)
            cout<<mark[i][j]<<endl;
        cout<<"The total mark is "<<total[i];
    }
}

Exam Tips:

a) A 2D array mark[5][3] has one row for each student and one column for each subject.
b) Reset total[i] to 0 for every student before adding the marks.

 

Question 59: Differentiate linear search and binary search.

Answer:

Linear searchBinary search
Each element of the array is compared with the element to be searched, starting from the first element. If a match is found, the position of the element is returned.It uses the divide and conquer technique and can be performed only on a sorted array. The element is first compared with the middle element.
The array need not be sorted.The array must be sorted.
It is slow for large arrays.It is faster for large arrays.

In binary search there are three possibilities after comparing with the middle element: the element is the middle element (search finished); it is less than the middle element (the search continues in the lower half); or it is greater than the middle element (the search continues in the upper half). The process is repeated.

Exam Tips:

a) Present the answer in a table; compare at least the method, the need for sorted data and the speed.

 

Question 60: Differentiate bubble sort and selection sort.

Answer:

Bubble sortSelection sort
It is a simple sorting method. Two adjacent elements are compared and, if they are out of order, they are interchanged.The array is divided into two parts, the sorted part and the unsorted part. The smallest element of the unsorted part is searched for and exchanged with the first element of the unsorted part.
After the first iteration the largest element (ascending order) or the smallest element (descending order) reaches the end of the array. The process continues.After each iteration the sorted part grows by one element. The process continues until the unsorted part is empty.

Exam Tips:

a) Mention the key idea of each method: neighbours are swapped in bubble sort, and the minimum is selected in selection sort.

 

Question 61: Write a program to read a string and a character, and find the character in the string using linear search.

Answer:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char str[80], ch;
    int i, n = 0, pos;
    cout<<"Enter a string";
    gets(str);
    cout<<"Enter the character to be searched";
    cin>>ch;
    for(i = 0; str[i] != '\0'; i++)
        if(str[i] == ch)
        {
            n++;
            pos = i;
        }
    if(n == 1)
        cout<<"The character is present in the position "<<pos + 1;
    else if(n > 1)
        cout<<"The character is present "<<n<<" times";
    else
        cout<<"The character is not present in the string";
}

Exam Tips:

a) Compare every character of the string with the given character; count the matches in n.
b) Position = index + 1 because indexing starts at 0.

 

Question 62: Write a program to read the marks of 10 students and then read a mark and check whether it is in the array or not using binary search.

Answer:

The marks are first sorted (binary search needs a sorted array) and then searched.

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    int l = 0, u = 9, m, n, i, j, mark[10], t;
    for(i = 0; i < 10; i++)
    {
        cout<<"Enter the mark of student "<<i + 1<<":";
        cin>>mark[i];
    }
    cout<<"Enter the mark to be searched";
    cin>>n;
    for(i = 0; i < 9; i++)
        for(j = 0; j < 9 - i; j++)
            if(mark[j] > mark[j + 1])
            {
                t = mark[j];
                mark[j] = mark[j + 1];
                mark[j + 1] = t;
            }
    cout<<"The sorted marks are given below";
    for(i = 0; i < 10; i++)
        cout<<mark[i]<<",";
    while(l <= u)
    {
        m = (l + u) / 2;
        if(mark[m] == n)
        {
            cout<<"\n"<<mark[m]<<" is found at position "<<m + 1;
            exit(0);
        }
        else if(mark[m] < n)
            l = m + 1;
        else
            u = m - 1;
    }
    cout<<"\nMark does not exist";
}

Exam Tips:

a) Binary search needs a sorted array, so sort first (bubble sort here).
b) Keep lower (l) and upper (u) bounds; find the middle m = (l + u) / 2 each time and adjust the bounds.
c) If the loop ends without a match, print that the mark does not exist.

 

Question 63: Write a program to reverse a string without using a function.

Answer:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int i, j, len;
    char str[80], revstr[80];
    cout<<"Enter a string";
    gets(str);
    for(len = 0; str[len] != '\0'; len++);
    for(i = 0, j = len - 1; str[i] != '\0'; i++, j--)
        revstr[i] = str[j];
    revstr[i] = '\0';
    cout<<"The string in reverse is "<<revstr;
}

Exam Tips:

a) Find the length first, then copy the characters from the last to the first into a second array.
b) End the new string with the null character \0, otherwise it will not print correctly.

 

Question 64: Write a program to read a string and find the number of vowels, consonants and special characters.

Answer:

#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main()
{
    char str[100];
    int i, vowel = 0, consonant = 0, special = 0;
    cout<<"Enter a string:";
    gets(str);
    for(i = 0; str[i] != '\0'; i++)
        if((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122))
            switch(toupper(str[i]))
            {
                case 'A':
                case 'E':
                case 'I':
                case 'O':
                case 'U': vowel++; break;
                default: consonant++;
            }
        else
            special++;
    cout<<"The number of vowels is "<<vowel<<", the number of consonants is "<<consonant<<" and the number of special characters is "<<special;
}

Exam Tips:

a) Letters have ASCII values 65 to 90 (capitals) and 97 to 122 (small); anything else is a special character.
b) Convert to upper case with toupper() so you test only five vowels.

 

Question 65: Given the word "COMPUTER", write a C++ program to reverse the word without using any string functions.

Answer:

#include<iostream>
using namespace std;
int main()
{
    char a[9] = "COMPUTER";
    int i;
    for(i = 7; i >= 0; i--)
    {
        cout<<a[i];
    }
}

Output: RETUPMOC

Exam Tips:

a) The word has 8 characters, so the last letter is at index 7; index 8 holds the null character.
b) Print the characters using a loop that counts downwards.

 

Question 66: Write a program to accept the marks of 10 students and find the largest and smallest marks in the list.
OR
Write a C++ program to store the scores of 10 batsmen of a school cricket team and find the largest and smallest scores.

Answer:

#include<iostream>
using namespace std;
int main()
{
    int mark[10], i, big, small;
    cout<<"Enter the marks:";
    for(i = 0; i < 10; i++)
        cin>>mark[i];
    big = mark[0];
    small = mark[0];
    for(i = 1; i < 10; i++)
    {
        if(mark[i] > big)
            big = mark[i];
        if(mark[i] < small)
            small = mark[i];
    }
    cout<<"Largest mark is "<<big<<endl;
    cout<<"Smallest mark is "<<small;
}

Exam Tips:

a) Assume the first element is both the largest and the smallest, then compare the remaining elements with these two values.
b) The same program works for the batsmen scores; only the names change.

 

Question 67: Write the names of two searching methods in arrays. Prepare a chart that shows the comparison of the two searching methods. (March 2015)

Answer:

Searching is the process of finding the position of a given element. The two methods are linear search and binary search.

PointLinear searchBinary search
MethodEach element is compared with the element to be searched, starting from the first element. When it is found, its position is returned.Divide and conquer: the element is compared with the middle element and the search continues in the lower or upper half.
ArrayThe array need not be sorted.The array must be sorted.
SpeedSlower for large arrays.Faster for large arrays.

In binary search, after comparing with the middle element there are three possibilities: the element is the middle element (search finished); the element is less than the middle element (the upper bound is moved before the middle); or the element is greater than the middle element (the lower bound is moved after the middle). The process is repeated.

Exam Tips:

a) Name both methods and then draw the table; a table is what "chart" means here.
b) Compare at least three points: the working, the need for a sorted array and the speed.

 

Question 68: Write a C++ program to illustrate array traversal. (SAY 2015)

Answer:

#include<iostream>
using namespace std;
int main()
{
    int i, mark[50];
    for(i = 0; i < 50; i++)
    {
        cout<<"Enter mark "<<i + 1<<": ";
        cin>>mark[i];
    }
    cout<<"\nThe mark of 50 students after adding bonus mark 10 is given below \n";
    for(i = 0; i < 50; i++)
        cout<<mark[i] + 10<<endl;
}

Exam Tips:

a) Traversal means visiting each element once; here the first loop reads each element and the second loop displays it after adding 10.

 

Question 69: Define an array. Also write an algorithm for searching an element in the array using any one method that you are familiar with. (March 2016)

Answer:

An array is a collection of elements of the same data type. The index of the first element is 0 (zero) and the index of the last element is size - 1.

Searching is the process of finding the position of a given element. Algorithm for linear search:
1. Start from the first element of the array.
2. Compare the element to be searched with the current element.
3. If they are equal, the search is successful; print the position and stop.
4. Otherwise move to the next element and repeat step 2.
5. If the end of the array is reached without a match, the element is not present.

Binary search (for a sorted array) is the other method. It uses the divide and conquer technique: the element is compared with the middle element. If it is equal, the search ends; if it is less, the search continues in the lower half; if it is greater, it continues in the upper half. This is repeated.

Exam Tips:

a) Write the definition first, then number the steps of the algorithm.
b) Use the method you know best; linear search is the easiest to write.

 

Question 70: 1. Finding the sum of all elements in an array is an example of the ________ operation.
2. If 24, 45, 98, 56, 76, 24 and 15 are the elements of an array, illustrate the working of selection sort for arranging the elements in descending order. (SCERT Sample Paper I)

Answer:

1. Traversal

2. In selection sort the array is divided into a sorted part and an unsorted part. The largest element of the unsorted part is searched for and exchanged with the first element of the unsorted part (for descending order). This is repeated.
Step I: 24, 45, 98, 56, 76, 24, 15. The largest element, 98, is exchanged with the 1st element: 98, 45, 24, 56, 76, 24, 15.
Step II: 98 is now fixed. The next largest from the remaining 6 numbers is 76; it is exchanged with the 2nd element: 98, 76, 24, 56, 45, 24, 15.
Step III: the largest of the remaining numbers is 56; it is exchanged with the 3rd element: 98, 76, 56, 24, 45, 24, 15.
Step IV: the largest of the remaining numbers is 45; it is exchanged with the 4th element: 98, 76, 56, 45, 24, 24, 15.
The remaining elements 24, 24, 15 are already in descending order.
Finally the sorted array in descending order is 98, 76, 56, 45, 24, 24, 15.

Exam Tips:

a) Show the array after every step; the step-wise working carries the marks.
b) For descending order select the largest element each time; for ascending order select the smallest.

 

Question 71: Read the following C++ statement: int AR[10];
1. How many bytes will be allocated for this array?
2. Write an algorithm to sort this array using the bubble sort method. (SCERT Sample Paper II)

Answer:

1. An integer needs 4 bytes, so AR[10] needs 10 × 4 = 40 bytes.

2. Sorting means arranging the elements of an array in an order (ascending or descending).
Bubble sort algorithm (ascending order):
1. Compare the first two adjacent elements. If the first is greater than the second, interchange them.
2. Move to the next pair of adjacent elements and repeat the comparison and interchange till the end of the array. After this first pass, the largest element is at the end of the array.
3. Repeat the process for the remaining elements (leaving out the last element each time) until no more passes are left.
4. The array is now sorted.

Exam Tips:

a) Show the calculation for the bytes: number of elements × size of an integer.
b) Write the algorithm as numbered steps; mention that the largest (or smallest) element reaches the end after each pass.

 

Question 72: Explain "Call by Value" and "Call by Reference" methods of function calling with the help of a suitable example. (September 2016)

Answer:

There are two types of function calling: call by value and call by reference.

1. Call by value: the copy of the original value is passed to the function. If the function makes any change, the original value is not affected.
Example:

#include<iostream>
using namespace std;
void swap(int x, int y)
{
    int temp;
    temp = x;
    x = y;
    y = temp;
}
int main()
{
    int a, b;
    cout<<"Enter 2 nos";
    cin>>a>>b;
    cout<<"The values before swap a="<<a<<" and b="<<b;
    swap(a, b);
    cout<<"\nThe values after swap a="<<a<<" and b="<<b;
}

There is no change in the values.

2. Call by reference: the address of the original value is passed to the function (the parameters are declared with &). If the function makes any change, the original value is affected.
Example:

#include<iostream>
using namespace std;
void swap(int &x, int &y)
{
    int temp;
    temp = x;
    x = y;
    y = temp;
}
int main()
{
    int a, b;
    cout<<"Enter 2 nos";
    cin>>a>>b;
    cout<<"The values before swap a="<<a<<" and b="<<b;
    swap(a, b);
    cout<<"\nThe values after swap a="<<a<<" and b="<<b;
}

There is a change in the values: a and b are interchanged.

Exam Tips:

a) Use the same swap example for both methods so that the difference is visible in the output.
b) The only difference in the code is the & in the parameters of the reference version.

 

Question 73: What is an array? Write a C++ program to declare and use a single dimensional array for storing the Computer Science marks of all students in your class. (September 2016)

Answer:

An array is a collection of elements of the same data type. With the same name we can store many elements, and the first, second, third and so on are distinguished by using the index (subscript). The first element has index 0, the second has index 1, and so on.

Program (taking 60 students):

#include<iostream>
using namespace std;
int main()
{
    int marks[60], i;
    for(i = 0; i < 60; i++)
    {
        cout<<"Enter mark of student "<<i + 1<<":";
        cin>>marks[i];
    }
    cout<<"The marks are given below\n";
    for(i = 0; i < 60; i++)
        cout<<marks[i]<<endl;
}

Exam Tips:

a) Define the array, then show a declaration, input loop and output loop.
b) The array size must be at least the number of students in the class.

 

Question 74: Write an algorithm for arranging the elements of an array in ascending order using bubble sort. (March 2017)

Answer:

Algorithm for bubble sort (ascending order) for an array n of 5 elements:
1. Read the 5 numbers into the array n.
2. Repeat steps 3 and 4 for i = 0 to 3.
3. For j = 0 to 3 - i, compare n[j] with n[j + 1].
4. If n[j] is greater than n[j + 1], interchange them using a temporary variable.
5. Display the sorted array.

The corresponding program:

#include<iostream>
using namespace std;
int main()
{
    int i, j, n[5], t;
    for(i = 0; i < 5; i++)
    {
        cout<<"Enter number "<<i + 1<<":";
        cin>>n[i];
    }
    for(i = 0; i < 4; i++)
        for(j = 0; j < 4 - i; j++)
            if(n[j] > n[j + 1])
            {
                t = n[j];
                n[j] = n[j + 1];
                n[j + 1] = t;
            }
    cout<<"The sorted array is given below";
    for(i = 0; i < 5; i++)
        cout<<n[i]<<",";
}

Exam Tips:

a) Write the algorithm as numbered steps; adding the program makes the answer complete.
b) The inner loop runs from 0 to 3 - i, since the last i elements are already in their correct places.

 

Five Mark Questions and Answers

Question 75: Write a program to perform matrix addition, subtraction and multiplication.

Answer:

The program uses a separate function for each operation and a menu in main().

#include<iostream>
using namespace std;
void add()
{
    int m1[10][10], m2[10][10], m3[10][10], i, j, r, c;
    cout<<"Enter the number of rows";
    cin>>r;
    cout<<"Enter the number of columns";
    cin>>c;
    cout<<"Enter "<<r*c<<" elements for matrix 1";
    for(i = 0; i < r; i++)
        for(j = 0; j < c; j++)
            cin>>m1[i][j];
    cout<<"Enter "<<r*c<<" elements for matrix 2";
    for(i = 0; i < r; i++)
        for(j = 0; j < c; j++)
            cin>>m2[i][j];
    for(i = 0; i < r; i++)
        for(j = 0; j < c; j++)
            m3[i][j] = m1[i][j] + m2[i][j];
    cout<<"The first matrix is given below\n";
    for(i = 0; i < r; i++)
    {
        for(j = 0; j < c; j++)
            cout<<m1[i][j]<<"\t";
        cout<<endl;
    }
    cout<<"The second matrix is given below\n";
    for(i = 0; i < r; i++)
    {
        for(j = 0; j < c; j++)
            cout<<m2[i][j]<<"\t";
        cout<<endl;
    }
    cout<<"The resultant matrix is given below\n";
    for(i = 0; i < r; i++)
    {
        for(j = 0; j < c; j++)
            cout<<m3[i][j]<<"\t";
        cout<<endl;
    }
}
void sub()
{
    int m1[10][10], m2[10][10], m3[10][10], i, j, r, c;
    cout<<"Enter the number of rows";
    cin>>r;
    cout<<"Enter the number of columns";
    cin>>c;
    cout<<"Enter "<<r*c<<" elements for matrix 1";
    for(i = 0; i < r; i++)
        for(j = 0; j < c; j++)
            cin>>m1[i][j];
    cout<<"Enter "<<r*c<<" elements for matrix 2";
    for(i = 0; i < r; i++)
        for(j = 0; j < c; j++)
            cin>>m2[i][j];
    for(i = 0; i < r; i++)
        for(j = 0; j < c; j++)
            m3[i][j] = m1[i][j] - m2[i][j];
    cout<<"The first matrix is given below\n";
    for(i = 0; i < r; i++)
    {
        for(j = 0; j < c; j++)
            cout<<m1[i][j]<<"\t";
        cout<<endl;
    }
    cout<<"The second matrix is given below\n";
    for(i = 0; i < r; i++)
    {
        for(j = 0; j < c; j++)
            cout<<m2[i][j]<<"\t";
        cout<<endl;
    }
    cout<<"The resultant matrix is given below\n";
    for(i = 0; i < r; i++)
    {
        for(j = 0; j < c; j++)
            cout<<m3[i][j]<<"\t";
        cout<<endl;
    }
}
void mul()
{
    int m1[10][10], m2[10][10], m3[10][10], i, j, k, r, c, m, n;
    cout<<"Enter the order of first matrix";
    cin>>r>>c;
    cout<<"Enter the order of second matrix";
    cin>>m>>n;
    if(c != m)
        cout<<"The 2 matrices cannot be multiplied";
    else
    {
        cout<<"Enter "<<r*c<<" elements for matrix 1\n";
        for(i = 0; i < r; i++)
            for(j = 0; j < c; j++)
                cin>>m1[i][j];
        cout<<"Enter "<<m*n<<" elements for matrix 2\n";
        for(i = 0; i < m; i++)
            for(j = 0; j < n; j++)
                cin>>m2[i][j];
        for(i = 0; i < r; i++)
            for(j = 0; j < n; j++)
            {
                m3[i][j] = 0;
                for(k = 0; k < c; k++)
                    m3[i][j] = m3[i][j] + m1[i][k] * m2[k][j];
            }
        cout<<"The first matrix is given below\n";
        for(i = 0; i < r; i++)
        {
            for(j = 0; j < c; j++)
                cout<<m1[i][j]<<"\t";
            cout<<endl;
        }
        cout<<"The second matrix is given below\n";
        for(i = 0; i < m; i++)
        {
            for(j = 0; j < n; j++)
                cout<<m2[i][j]<<"\t";
            cout<<endl;
        }
        cout<<"The resultant matrix is given below\n";
        for(i = 0; i < r; i++)
        {
            for(j = 0; j < n; j++)
                cout<<m3[i][j]<<"\t";
            cout<<endl;
        }
    }
}
int main()
{
    int ch;
    do
    {
        cout<<"\n1.Addition\n2.Subtraction\n3.Multiplication\nEnter your choice (Zero for exit)";
        cin>>ch;
        switch(ch)
        {
            case 1: add(); break;
            case 2: sub(); break;
            case 3: mul(); break;
            default: cout<<"Thank you";
        }
    } while(ch != 0);
}

Exam Tips:

a) Addition and subtraction need two matrices of the same order; multiplication needs the number of columns of the first to equal the number of rows of the second.
b) For multiplication, set each result element to 0 first and then add the products m1[i][k] * m2[k][j] in a third loop.
c) Use a do-while loop with a switch to build the menu; entering 0 exits the program.

 

Kerala Board Solutions for Class 11 Computer Science Chapter 08 Arrays

Accessing Chapter 08 Arrays Solutions

Review comprehensive exercise answers for Class 11 Computer Science Chapter 08 Arrays. Fully updated to match current Kerala Board syllabus guidelines, these textbook solutions help students verify their work and maintain accurate study notes.

Concept-Driven Answers for Class 11 Computer Science

Beyond providing final answers, these guides offer step-by-step breakdowns for complex queries in the Class 11 Computer Science module. This approach helps students balance theoretical depth with practical problem-solving skills required for Kerala Board exams.

Maximizing Study Efficiency

Consistent practice with these solution guides cultivates faster problem-solving habits and clearer logical structuring. For a complete preparation experience, pair these textbook answers with our dedicated revision notes and sample papers for Class 11 Computer Science.

FAQs

Where can I find the latest Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers for the 2026-27 session?

The complete and updated Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers is available for free on StudiesToday.com. These solutions for Class 11 Computer Science are as per latest Kerala Board curriculum.

Are the Computer Science Kerala Board solutions for Class 11 updated for the new 50% competency-based exam pattern?

Yes, our experts have revised the Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.

How do these Class 11 Kerala Board solutions help in scoring 90% plus marks?

Toppers recommend using Kerala Board language because Kerala Board marking schemes are strictly based on textbook definitions. Our Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers will help students to get full marks in the theory paper.

Do you offer Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers in multiple languages like Hindi and English?

Yes, we provide bilingual support for Class 11 Computer Science. You can access Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers in both English and Hindi medium.

Is it possible to download the Computer Science Kerala Board solutions for Class 11 as a PDF?

Yes, you can download the entire Kerala Plus One Computer Science Chapter 8 Arrays Questions and Answers in printable PDF format for offline study on any device.