Kerala Plus Two Computer Application Chapter 2 Arrays Questions and Answers

Official Kerala Board Solutions for Class 12 Computer Application: Chapter 02 Arrays

Explore reliable textbook solutions for Chapter 02 Arrays tailored for Class 12 learners. Utilizing these Computer Application answers ensures thorough preparation and strengthens foundational knowledge before final Kerala Board evaluations.

Chapter-wise Solutions for Computer Application: Chapter 02 Arrays

Access the complete solution PDF for Class 12 Computer Application below. Regular practice with these targeted textbook answers builds familiarity with standard question patterns and helps secure higher marks in final school evaluations.

One Mark Questions and Answers

Question 1: Which of the following is not true for an array?
(a) It is easy to represent and manipulate array variables
(b) An 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.

Exam Tips:

a) An array always holds elements of the same data type, so 'dissimilar elements' is the false statement.

 

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

Answer:

It is not valid. The size of an array must be given in square brackets, not in parentheses. The correct declaration is int mark[50];

Exam Tips:

a) Remember: square brackets [ ] are used for array size and subscripts; parentheses ( ) are for function calls.
b) Write the corrected declaration in full, ending with a semicolon.

 

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, because indexing starts at 0.

 

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

Answer:

0

Exam Tips:

a) In C++ the subscript of the first element of every array is 0.

 

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) A for loop that runs the subscript from 0 to size - 1 is the usual way to read or print every element.

 

Question 7: Write down the memory consumed (in bytes) by each of the following:
1. int age[10];
2. char name[10];
3. int age[10][10];

Answer:

1. 4 x 10 = 40 bytes (an int takes 4 bytes)
2. 1 x 10 = 10 bytes (a char takes 1 byte)
3. 4 x 10 x 10 = 400 bytes (100 elements of 4 bytes each)

Exam Tips:

a) Memory of an array = size of data type x number of elements.
b) For a 2D array, the number of elements is rows x columns.

 

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

Answer:

(d) 0

Exam Tips:

a) When fewer values are given than the size, the remaining elements are automatically set to 0. age[3] is the fourth element, which was not given a value.

 

Question 9: The elements of a 2-dimensional array can be read using a ______ loop.

Answer:

Nested loop

Exam Tips:

a) The outer loop moves through the rows and the inner loop through the columns.

 

Question 10: ______ is the process of reading or visiting each element of an array.

Answer:

Traversal

Exam Tips:

a) Traversal means visiting every element once, for example to print them or find their sum.

 

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

Answer:

(c) traversal

Exam Tips:

a) Finding a total requires visiting every element once, which is traversal.

 

Question 12: The elements of an array of size ten are numbered from ______ to ______.

Answer:

0 to 9

Exam Tips:

a) Subscripts run from 0 to size - 1.

 

Question 13: 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

Exam Tips:

a) Element mark[n] is always the (n + 1)th element because counting starts from mark[0].

 

Question 14: When a multidimensional array is accessed, each array index is
(a) separated by a 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

Exam Tips:

a) In C++ each index gets its own pair of brackets, as in a[2][3]. Writing a[2,3] is wrong.

 

Question 15: 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];

Exam Tips:

a) Always add one extra location for the null character '\0' that ends every string.

 

Question 16: ______ is a collection of elements of the same data type.

Answer:

Array

Exam Tips:

a) Keep the definition in mind: same data type, one common name, continuous memory locations.

 

Question 17: Following are some statements about arrays. Identify the correct statement(s).
(a) An array is a collection of elements of the same data type.
(b) An array cannot be initialised at the time of declaration.
(c) An array allocates continuous memory.
(d) An array element can be accessed using an index or subscript.

Answer:

Statements (a), (c) and (d) are correct.
Statement (b) is wrong, because an array can be initialised at the time of declaration, for example int a[3] = {1, 2, 3};

Exam Tips:

a) Read every option before answering; here three options are true and only one is false.
b) If asked for the incorrect statement, the answer is (b).

 

Question 18: Which of the following is the correct declaration of an array?
(a) int a(10);
(b) int 10[a];
(c) a[1] int;
(d) int a[10];

Answer:

(d) int a[10];

Exam Tips:

a) Order of an array declaration: data type, array name, size in square brackets.

 

Question 19: Which is the last subscript of the array int m[25]?
(a) 24
(b) 25
(c) 0
(d) 26

Answer:

(a) 24

Exam Tips:

a) Last subscript = size - 1 = 25 - 1 = 24.

 

Question 20: The memory size of the data type float is 4 bytes. What is the total number of bytes required for the declaration float salary[10];?
(a) 10
(b) 4
(c) 40
(d) 400

Answer:

(c) 40 (4 x 10 = 40 bytes)

Exam Tips:

a) Multiply the size of one element by the number of elements.

 

Question 21: int num[100]; The above statement declares an array named num that can store a maximum of ______ integer numbers.
(a) 99
(b) 100
(c) 101
(d) any number

Answer:

(b) 100

Exam Tips:

a) The size in the declaration is the number of elements (100); only the last index is 99.

 

Question 22: If int a[10]; is an array, which element of the array is referred to as a[4]?

Answer:

The fifth element.

Exam Tips:

a) a[0] is the first element, so a[4] is the fifth.

 

Question 23: Consider the array declarations int A[ ] = {4, 5, 8}; int B[ ] = {2, 10};
Write a valid C++ statement to find the difference between the last element of array B and the first element of array A.

Answer:

B[1] - A[0]; (or A[0] - B[1];)

Exam Tips:

a) B has 2 elements, so its last element is B[1]; A's first element is A[0].
b) To display the result you can write cout << B[1] - A[0];

 

Question 24: Consider the following code and predict the output.
int sum = 0;
int a[5] = {1, 2, 3, 4, 5};
for (i = 0; i < 4; ++i)
{
    sum = sum + a[i];
}
cout << sum;

Answer:

10
The loop runs only for i = 0 to 3, so it adds 1 + 2 + 3 + 4 = 10. The last element (5) is not added.

Exam Tips:

a) Check the loop condition carefully: i < 4 stops before a[4].
b) Trace the value of sum after each iteration to avoid mistakes.

 

Question 25: Which data type is used to declare a variable that holds string data?

Answer:

The data type char is used, as a character array (for example char name[20];).

Exam Tips:

a) A string in C++ is stored as an array of characters ending with '\0'.

 

Question 26: The terminating character of a string array is ______.

Answer:

'\0' (the null character)

Exam Tips:

a) The null character is added automatically when a string is stored, so it needs one extra byte.

 

Question 27: Write a statement to store the string "NO SMOKING" in a character array named ARR of minimum size.

Answer:

char ARR[11] = "NO SMOKING";
The string has 10 characters (including the space), plus 1 byte for the null character, so the minimum size is 11.

Exam Tips:

a) Count the space as a character.
b) Add 1 to the character count for '\0' to get the minimum size.

 

Two Mark Questions and Answers

Question 28: Given below are some array declarations. Pick the odd one 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 the only valid array declaration; all the others are invalid.

Exam Tips:

a) Check each declaration for the correct order: data type (in lower case), name, then a positive size in square brackets.
b) 'Float' is wrong because C++ keywords are in lower case; 'double [50]' has no array name.

 

Question 29: Is the statement char text[] = "COMPUTER"; true or false? Justify.

Answer:

True. It is a valid single-dimensional character array. When the size is not given, the compiler allocates memory equal to the number of characters plus one byte for the null character. Here "COMPUTER" has 8 characters, so 9 bytes are allocated.

Exam Tips:

a) Mention that the size can be omitted when the array is initialised at declaration.
b) Show the byte count: 8 characters + 1 null character = 9 bytes.

 

Question 30: 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. Using ordinary variables, we would have to declare 50 separate variables, one for each student. This is very laborious.
2. Yes. An array is a more efficient way. With a single name we can store many elements of the same type. For example, int mark[50]; stores 50 marks. The first mark is in mark[0], the second in mark[1], and so on, and the fiftieth mark is in mark[49].

Exam Tips:

a) Answer both parts separately with numbering.
b) Give an example declaration and mention the first and last subscripts.

 

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

Answer:

The last location stores the null character ('\0'), because every string is automatically terminated by a null character. The array has 8 locations: 7 for the letters and 1 for '\0'.

Exam Tips:

a) The justification is the key point: a string always ends with '\0'.

 

Question 32: Explain the need for arrays.

Answer:

An array is a collection of elements of the same type under one name. The elements are distinguished by their index or subscript. To store the marks of 50 students without an array, we would have to declare 50 variables, which is laborious. This is why arrays are needed. With an array it is 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) Include the definition, the problem with ordinary variables and an example declaration.
b) Mention that arrays let us process all elements with a single loop.

 

Question 33: Consider the following code and predict the output.
int a[5] = {6, 8, 10, 20, 40};
cout << "\n" << a[3];
cout << "\n" << a[1] + a[4];

Answer:

20 (the fourth element, a[3])
48 (sum of the second element 8 and the fifth element 40, that is 8 + 40 = 48)

Exam Tips:

a) Remember a[3] is the fourth element, not the third.
b) Each "\n" prints the value on a new line.

 

Question 34: Suppose you need to store the values 10, 20, 30, 40 and 50 in an array. Write different methods to do this.

Answer:

Method 1 (initialisation at declaration):
int a[5] = {10, 20, 30, 40, 50};
OR
int a[ ] = {10, 20, 30, 40, 50};
Method 2 (assigning each element separately):
int a[5];
a[0] = 10;
a[1] = 20;
a[2] = 30;
a[3] = 40;
a[4] = 50;

Exam Tips:

a) Show at least two methods clearly labelled.
b) When the size is omitted, the compiler takes the size from the number of values given.

 

Question 35: What would be the appropriate array declaration to store the following?
1. Name of a student
2. Age of 20 students
3. Marks of 6 subjects
4. Average mark of 10 students in 5 subjects

Answer:

1. char name[20];
2. int age[20];
3. int mark[6];
4. float avg[10];

Exam Tips:

a) Choose float for averages, since an average can have a decimal part.
b) Use char arrays for names and int arrays for whole numbers like age and marks.

 

Question 36: Consider the following code and predict the output.
int A[5] = {11, 12, 13, 14, 15};
int i;
for (i = 4; i >= 0; --i)
{
    cout << "\n" << A[i];
}

Answer:

It prints the array in reverse order, one value per line:
15
14
13
12
11

Exam Tips:

a) The loop starts from the last index (4) and goes down to 0, so the order is reversed.
b) "\n" before each value puts every number on a new line.

 

Question 37: Predict the output of the following code segment.
int K[ ] = {1, 2, 3, 4};
for (int i = 0; i < 4; i++)
    cout << K[i] * K[i] << "\t";

Answer:

1    4    9    16
Each element is multiplied by itself: 1 x 1 = 1, 2 x 2 = 4, 3 x 3 = 9, 4 x 4 = 16. The values are separated by tab spaces.

Exam Tips:

a) "\t" prints a tab space, so all values appear on the same line.
b) Write the working for each element to justify the output.

 

Question 38: Consider the following code and predict the output. Justify your answer.
int A[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = 0, i;
for (i = 0; i < 10; ++i)
{
    if (A[i] % 2 == 0)
    {
        sum = sum + A[i];
    }
}
cout << "\nSum=" << sum;

Answer:

Sum=30
The condition A[i] % 2 == 0 is true only for even numbers, so the program adds the even numbers in the array: 2 + 4 + 6 + 8 + 10 = 30.

Exam Tips:

a) Explain what the condition checks (even numbers) as the justification.
b) Include the text "Sum=" in the output, exactly as the cout statement prints it.

 

Question 39: Predict the output of the following C++ statements.
char str[8] = "WELCOME";
cout << "\n" << str[3];
cout << "\n" << str;

Answer:

C (the fourth character, str[3])
WELCOME

Exam Tips:

a) Count positions from 0: W(0) E(1) L(2) C(3).
b) Printing the array name str displays the whole string.

 

Question 40: How many bytes will be allocated in memory for storing the string "MY SCHOOL"? Justify your answer.

Answer:

10 bytes in total. 9 bytes store the 9 characters of MY SCHOOL (including 1 byte for the space) and 1 byte stores the null character.

Exam Tips:

a) Do not forget to count the space and the null character.

 

Three Mark Questions and Answers

Question 41: 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 this 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];
    }
    for (i = 0; i < 50; i++)
        mark[i] = mark[i] + 10;
    cout << "\nThe marks of 50 students after adding bonus mark 10 are given below\n";
    for (i = 0; i < 50; i++)
        cout << mark[i] << endl;
    return 0;
}

Exam Tips:

a) The key step is mark[i] = mark[i] + 10 inside a loop, which changes every element of the array.
b) Use one loop to read, one to modify and one to display the marks.

 

Question 42: 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;
    return 0;
}

Exam Tips:

a) tolower() converts each letter to lower case, so both capital and small vowels are counted. It needs the header cctype (ctype.h).
b) The loop runs until the null character '\0' is reached, so it works for a name of any length.

 

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

Answer:

Program (when the words are separated by single spaces):
#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;
    return 0;
}
Program (when there may be more than one space between words):
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int i, words = 0;
    char str[80];
    cout << "Enter a string\n";
    gets(str);
    for (i = 0; str[i] != '\0'; i++)
        if (str[i] != 32 && (i == 0 || str[i - 1] == 32))
            words++;
    cout << "The number of words is " << words;
    return 0;
}
For the given string, the output is: The number of words is 4

Exam Tips:

a) 32 is the ASCII code of the space character; you can also write ' ' instead of 32.
b) In the first program, the number of words is one more than the number of spaces.
c) The second program counts a word each time a non-space character comes after a space (or at the start), so extra spaces do not affect the count.

 

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

Answer:

The meaningful word is obtained by reversing the given word (AMBULANCE).
#include <iostream>
#include <cstdio>
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]);
    return 0;
}
Output for ECNALUBMA: AMBULANCE

Exam Tips:

a) First find the length with a loop, then print the characters from index len - 1 down to 0.
b) Mention the expected output (AMBULANCE) to show the program works.

 

Question 45: Explain the different types of arrays.

Answer:

1. Single dimensional array: It has only one index or subscript. The index starts from 0 and ends at size - 1.
Example: int n[50]; char name[10];
2. Multidimensional 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 runs from 0 to (number of rows - 1) and the column index runs from 0 to (number of columns - 1).
Example: int n[10][10]; can store 10 x 10 = 100 elements. The first element is n[0][0] and the 100th element is n[9][9].

Exam Tips:

a) Give an example declaration for each type.
b) For a 2D array, state how to find the number of elements (rows x columns) and name the first and last elements.

 

Question 46: 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;
    return 0;
}

Exam Tips:

a) Initialise total to 0 before adding marks to it.
b) Adding each mark to total while reading saves a separate loop.

 

Question 47: Explain the different array operations in detail.

Answer:

1. Traversal: Visiting and processing every element of an array one by one is called traversal (for example, printing all elements or finding their sum).
2. Searching: Checking whether a given element is present in the array or not is called searching (for example, linear search).
3. Sorting: Arranging the elements of an array in ascending or descending order is called sorting (for example, bubble sort).

Exam Tips:

a) Give a one-line example for each operation to earn full marks.
b) Name a method for searching (linear search) and for sorting (bubble sort or selection sort).

 

Question 48: 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];
    }
    return 0;
}
Output: RETUPMOC

Exam Tips:

a) "COMPUTER" has 8 letters at indices 0 to 7; index 8 holds the null character.
b) Start the loop from the last letter and move backwards to index 0.

 

Question 49: Write statements to declare an array, initialise it with the numbers 1, 2, 3, 4, 5 and print 5, 4, 3, 2, 1.

Answer:

#include <iostream>
using namespace std;

int main()
{
    int a[5] = {1, 2, 3, 4, 5}, i;
    for (i = 4; i >= 0; i--)
        cout << a[i] << ",";
    return 0;
}

Exam Tips:

a) Initialise the array at declaration and print it with a loop running from index 4 down to 0.
b) Write the decrement as i-- (two minus signs); a single minus sign is an error.

 

Question 50: Consider the following array declaration. Write statements to count how many numbers are greater than zero.
int p[ ] = {-5, 6, -7, 0, 8, 9};

Answer:

#include <iostream>
using namespace std;

int main()
{
    int p[ ] = {-5, 6, -7, 0, 8, 9}, i, count = 0;
    for (i = 5; i >= 0; i--)
        if (p[i] > 0)
            count++;
    cout << "There are " << count << " numbers that are greater than zero";
    return 0;
}
Output: There are 3 numbers that are greater than zero

Exam Tips:

a) 0 is neither positive nor negative, so it is not counted; the positive numbers are 6, 8 and 9.
b) The loop can run in either direction; what matters is that every element is checked.

 

Question 51: Write a C++ program to read 10 integer values and find the largest number among them using an array.

Answer:

#include <iostream>
using namespace std;

int main()
{
    int n[10], i, big;
    cout << "Enter 10 integers:";
    for (i = 0; i < 10; i++)
        cin >> n[i];
    big = n[0];
    for (i = 0; i < 10; i++)
    {
        if (n[i] > big)
            big = n[i];
    }
    cout << "Largest number is " << big;
    return 0;
}

Exam Tips:

a) Start by assuming the first element n[0] is the largest, then compare it with every element.
b) Do not initialise big to 0; it fails if all numbers are negative.

 

Question 52: Write a C++ program to accept a string from the keyboard and find its length without using a function. For example, if "WELCOME" is accepted, the output will be 7.

Answer:

#include <iostream>
#include <cstdio>
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++;
    cout << "The length of the string " << str << " is " << len;
    return 0;
}

Exam Tips:

a) The loop counts characters until the null character (value 0) is reached.
b) gets() is used instead of cin so that strings with spaces are read fully.

 

Question 53: Consider the following C++ statements.
1.
char word[20];
cin >> word;
cout << word;
2.
char word[20];
gets(word);
puts(word);
If the string entered is "HAPPY NEW YEAR", predict the output in both cases and justify your answers.

Answer:

1. HAPPY
When cin is used to accept a string, a space acts as the delimiter. The part of the string after the space is not read.
2. HAPPY NEW YEAR
gets() reads all characters, including spaces, until the user presses the Enter key.

Exam Tips:

a) The difference between cin and gets() for strings with spaces is a frequently asked question.
b) Give the output and the reason separately for each case.

 

Question 54: Consider the following C++ statements.
char str[] = "NO\nSMOKING";
cout << str;
1. What is the output of the above code?
2. How many bytes will be allocated in memory for the variable str?

Answer:

1. The output is in two lines:
NO
SMOKING
2. A total of 11 bytes is allocated: 1 byte for '\n', 1 byte for '\0' (the null character added automatically) and 9 bytes for the remaining characters (N, O, S, M, O, K, I, N and G).

Exam Tips:

a) An escape sequence like \n is a single character and takes only 1 byte.
b) Add 1 byte for the null character at the end of the string.

 

Question 55: Write a C++ program to store a given string in an array and display it in reverse order without using string functions. For example, if ABCD is given, the output should be DCBA.

Answer:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    char str[80];
    int i, len = 0;
    cout << "Enter a string:";
    gets(str);
    for (i = 0; str[i] != '\0'; i++);
    len = i;
    for (i = len - 1; i >= 0; i--)
        cout << str[i];
    return 0;
}

Exam Tips:

a) The first for loop ends with a semicolon; it only moves i to the null character, so i gives the length.
b) Print from index len - 1 down to 0 to get the reversed string.

 

Five Mark Questions and Answers

Question 56: Collect the heights of 12 students from your class, of whom 7 are male and the others female. Suppose the male and female students are seated on two separate benches, and you are given a place where these 12 students must sit in a single 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 7 male students are stored in array m and the heights of the 5 female students in array f. Each array is sorted in ascending order, and then both are copied into a single array mf of 12 elements: first the male students, then the female students.
#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\n";
    for (i = 0; i < 12; i++)
        cout << mf[i] << ",";
    return 0;
}

Exam Tips:

a) The sorting used is bubble sort: adjacent elements are compared and swapped if they are out of order.
b) After the first copy loop, i is 7, so mf[i + j] places the female heights from mf[7] to mf[11].
c) Explain the logic in two or three lines before writing the code; it earns marks even if there is a small coding slip.

 

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

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 << "\n";
        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];
    }
    return 0;
}

Exam Tips:

a) Use a 2D array mark[5][3]: rows for students and columns for the 3 marks.
b) Reset total[i] to 0 for each student before adding that student's marks.
c) Nested loops are needed: the outer loop for students and the inner loop for marks.

 

Question 58: Write a program to read a string and a character, and find the character 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";
    return 0;
}

Exam Tips:

a) In linear search each element is compared with the search key one by one from the beginning.
b) pos + 1 is printed because positions are counted from 1 for the user, while the index starts from 0.
c) Handle all three cases: found once, found many times and not found.

 

Question 59: 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;
    return 0;
}

Exam Tips:

a) 65 to 90 are the ASCII codes of A to Z and 97 to 122 are those of a to z; any other character is counted as special.
b) toupper() converts the letter to capital so only upper-case vowels need to be checked in the switch.
c) Do not forget break after vowel++, otherwise the default case also runs.

 

Question 60: Write a program to accept the marks of 10 students and find the largest and smallest mark 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 score.

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];
    for (i = 0; i < 10; i++)
    {
        if (mark[i] > big)
            big = mark[i];
    }
    cout << "Largest mark is " << big;
    small = mark[0];
    for (i = 0; i < 10; i++)
    {
        if (mark[i] < small)
            small = mark[i];
    }
    cout << "\nSmallest mark is " << small;
    return 0;
}
The same program works for the scores of 10 batsmen; only the messages need to be changed.

Exam Tips:

a) Start both big and small with the first element mark[0].
b) Use > to find the largest and < to find the smallest.
c) Check that every opening brace { has a matching closing brace }.

 

Question 61: Write a C++ program to read 6 marks of a student and find the total and average mark.

Answer:

#include <iostream>
using namespace std;

int main()
{
    int mark[6], i, total = 0;
    float avg;
    for (i = 0; i < 6; i++)
    {
        cout << "Enter mark " << i + 1 << ":";
        cin >> mark[i];
        total = total + mark[i];
    }
    avg = total / 6.0;
    cout << "\nThe marks are given below\n";
    for (i = 0; i < 6; i++)
        cout << mark[i] << endl;
    cout << "The total mark is " << total << endl;
    cout << "The average mark is " << avg;
    return 0;
}

Exam Tips:

a) Divide by 6.0, not 6; dividing an int by 6 would drop the decimal part of the average.
b) Declare avg as float.

 

Question 62: Write a C++ program to accept a sentence and count the number of times the letter 's' occurs in it. For example, if the sentence is 'This is my school', the output should be 3.

Answer:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    char str[80], ch = 's';
    int i, n = 0, pos;
    cout << "Enter a string";
    gets(str);
    for (i = 0; str[i] != '\0'; i++)
        if (str[i] == ch)
        {
            n++;
            pos = i;
        }
    if (n == 1)
        cout << "The character s is present in the position " << pos + 1;
    else if (n > 1)
        cout << "The character s is present " << n << " times";
    else
        cout << "The character s is not present in the string";
    return 0;
}
For 'This is my school', the output is: The character s is present 3 times

Exam Tips:

a) Use gets() so that the whole sentence, including spaces, is read.
b) The comparison is case-sensitive, so a capital 'S' is not counted.

 

Free Kerala Board Textbook Explanations: Class 12 Computer Application Chapter 02 Arrays

Accessing Chapter 02 Arrays Solutions

Review comprehensive exercise answers for Class 12 Computer Application Chapter 02 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 12 Computer Application

Each solution includes detailed reasoning to foster genuine comprehension of Chapter 02 Arrays concepts. Reviewing these step-by-step breakdowns allows learners to master both analytical and descriptive questions expected in school evaluations.

Maximizing Study Efficiency

These resources act as an effective roadmap for daily homework tasks and independent study. Supplement your review of Chapter 02 Arrays with official sample papers and interactive practice tests available on our platform free of charge.

FAQs

Where can I find the latest Kerala Plus Two Computer Application Chapter 2 Arrays Questions and Answers for the 2026-27 session?

The complete and updated Kerala Plus Two Computer Application Chapter 2 Arrays Questions and Answers is available for free on StudiesToday.com. These solutions for Class 12 Computer Application are as per latest Kerala Board curriculum.

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

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

How do these Class 12 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 Two Computer Application Chapter 2 Arrays Questions and Answers will help students to get full marks in the theory paper.

Do you offer Kerala Plus Two Computer Application Chapter 2 Arrays Questions and Answers in multiple languages like Hindi and English?

Yes, we provide bilingual support for Class 12 Computer Application. You can access Kerala Plus Two Computer Application Chapter 2 Arrays Questions and Answers in both English and Hindi medium.

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

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