NCERT Solutions Class 12 Computer Science Arrays

Chapter - Arrays

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 X [4] = {100, 75, 10, 125};

int Go = random(2) + 2;

for (int i = Go; i<4; i ++)

cout<<X [i]<<"\$\$";

}

(i) 100\$\$75

(ii) 75\$\$10\$\$125\$\$

(iii) 75\$\$10\$\$

(iv) 10\$\$125\$

(iv) is correct option

Max. Value = 3

Min. Value = 2

Short Answer Type Questions-II[3 marks each]

Question 1. Write the definition 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

void grace_score(int score[].int size)

{

for(int i=0;i<size;i++)

{

if (score [i]<40)

score [i]=score[i]+5;

cout< }

}