CBSE Class 12 Computer Science C++ Chapter 8: Arrays NCERT Solutions
This chapter provides NCERT Solutions for Class 12 Computer Science focusing on Arrays, specifically one-dimensional arrays. Students will find detailed explanations and solutions to problems involving array manipulation, element access, and function definitions related to arrays. The solutions cover topics such as iterating through arrays, modifying elements based on conditions, and understanding the output of C++ programs that utilize arrays. These resources are designed to help students grasp the fundamental concepts of data structures, particularly arrays, and prepare effectively for their examinations by offering clear, step-by-step problem-solving guidance.
Quick info
| Board | CBSE |
|---|---|
| Class | Class 12 |
| Subject | Computer Science (C++) |
| Session | 2026 |
| Language | English |
| Type | NCERT Solutions |
| Chapter | Chapter 8 |
Chapter summary
Chapter 8 of the CBSE Class 12 Computer Science syllabus covers the essential concepts of one-dimensional arrays. The NCERT Solutions provide clear explanations and step-by-step solutions for various problems, including array initialization, traversal, element modification, and function implementation for array processing. This chapter focuses on building a strong foundation in handling sequential data structures in C++.
Learning outcomes
- Understand the concept of one-dimensional arrays in C++.
- Learn to declare, initialize, and access elements of an array.
- Implement functions to manipulate array elements based on given conditions.
- Analyze and predict the output of C++ programs involving arrays.
- Apply array concepts to solve programming problems.
PDF preview
Read page by page below. PDF is streamed from the official NCERT website — no download button on this page.
Questions and Solutions
Arrays
TOPIC-1
Data Structures and One-dimensional Arrays
Short Answer Type Questions-I[2 Marks Each]
Question 1.
Observe the following C++ code and find out, which out of the given options (i) to (iv) are the expected correct output. Also assign the maximum and minimum value that can be assigned to the variable 'Go'.
void main() { int <math>X [4] = \{100, 75, 10, 125\};</math> int <math>Go = random(2) + 2;</math> for (int <math>i = Go; i < 4; i ++)</math> cout<<X [i]<<"$$";
- 100$$75
- 75$$10$$125$$
- 75$$10$$
- 10$$125$
Answer:
- is correct option Max. <math>Value = 3</math> Min. Value = 2
Short Answer Type Questions-II[3 marks each]
Question 1.
Write the difintion of a function grace_score (int score [], int size) in C ++, which should check all the elements of the array and give an increase of 5 to those scores which are less than 40.
Example: if an array of seven integers is as follows: 45,35,85,80,33,27,90 After executing the function, the array content should be changed as follows: 45,40,85,80,38,32,90
Answer:
void grace score(int score[].int size) for (int <math>i=0</math>; <math>i < size</math>; <math>i++</math>) if (score [i]<40) score [i] = score[i] + 5; cout< }
Question 2.
Find the output of the following C+ + program: #include<iostream.h> void repch(char s[]) { for(int i=0;s[i]!='\0';i++) { if(((i\%2)!=0)) &&(s[i]!=s[i + 1])) { S[i]='@'; cout<<"Hello"; } else if (s[i]==s [i + 1]) { s[i+1]="!"; i++; } } void main() { char str[]="SUCCESS"; cout<<"Original String"<<str; repch(str);</pre> cout<<"Changed String"<<str; }</pre>
Answer: Original String SUCCESS Changed String S@C!ES!
Question 3.
Find the output of the following:
#include<iostream.h> void switchover (int A[],int N, int split) for (int <math>K=0</math>; <math>K<N</math>; <math>K++</math>) if(K<split)</pre> <math display="block">A [K] + = K;</math> else A[K] *=K; } void display(int A [], int N) for (in <math>K=0</math>; <math>K<N</math>; <math>K++</math>) <math>(K%2==0)</math>? Cout<math><<A[K]<<"%"</math>: cout << A[K] << endl; void main() { int H <math>[]</math> = {30, 40, 50, 20, 10, 5}; switchover(H, 6, 3); display(H, 6);
Common mistakes
- Incorrect array indexing (off-by-one errors).
- Errors in loop conditions for array traversal.
- Misunderstanding the scope and effect of array modifications within functions.
- Incorrectly handling string termination characters ('\0') in character arrays.
Revision tips
- Practice writing code for array initialization and traversal.
- Trace the execution of programs with arrays to predict output.
- Focus on understanding how functions modify arrays passed as arguments.
- Review the examples provided to solidify understanding of array manipulation techniques.
Practice MCQs
Q1. In the given C++ code snippet, what is the maximum possible value for the variable 'Go'?
Explanation: The variable 'Go' is assigned the result of random(2) + 2. Assuming random(2) can return 0 or 1, the maximum value is 1 + 2 = 3.
Content reviewed by the NCERT Help team. Editorial Team and update policy
NCERT Solutions PDF PDF on NCERT Help. URL unchanged for search indexing.