Topic Wise Solved Problems Question – Computer Sir Ki Class

CPP All :Topicwise Exam Questions: arrays-concepts-and-1-d-arrays
01E 3

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program .

```void main()
{
int A[]={10,12,15,17,20,30};
for(int i = 0; i<6; i++)
{
if(A[i]%2==0)
A[i] /= 2;
else if(A[i]%3==0)
A[i] /= 3;
if(A[i]%5==0)
A[i] /= 5;
}
for(i = 0; i<6; i++)
cout<<A[i]<<"#";
}```
CBSE12D-2017

03A 3

Write the definition of a function Reverse(int Arr[], int N) in C++, which should reverse the entire content of the array Arr having N elements, without using any other array.
Example: if the array Arr contains

 13 10 15 20 5

Then the array should become

 5 20 15 10 13

NOTE:
-The function should only rearrange the content of the array.
-The function should not copy the reversed content in another array.
-The function should not display the content of the array.

CBSE12D-2017

Value modification function of 1 D array using slab based conditions 2

Write the definition of a function FixPay(float Pay[], int N) in C++, which should
modify each element of the array Pay having N elements, as per the following
rules:

Existing Value of Pay Pay to be changed to
If less than 100000 Add 25% in the existing value
If >=100000 and <20000 Add 20% in the existing value
If >=200000 Add 15% in the existing value
CBSE12D-2016

03A 2

Write the definition of a function Alter(int A[], int N) in C++, which should change all the multiples of 5 in the array to 5 and rest of the elements as 0. For example, if an array of 10 integers is as follows:

 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] 55 43 20 16 39 90 83 40 48 25

After executing the function, the array content should be changed as follow:

 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] 5 0 5 0 0 5 0 5 0 5
CBSE12D-2015

03A 3

Write the definition of a function AddUp(int Arr[], int N) in C++, in which all even positions (i.e. 0,2,4,…) of the array should be added with the content of the element in the next position and odd positions (i.e. 1,3,5,…) elements should be incremented by 10.
Example: if the array Arr contains

 23 30 45 10 15 25

Then the array should become

 53 40 55 20 40 35

NOTE:

• The function should only alter the content in the same array.
• The function should not copy the altered content in another array.
• The function should not display the altered content of the array.
• Assuming, the Number of elements in the array are Even.
CBSE12A-2017

03A 2

Write the definition of a function FixSalary(float Salary[], int N) in C++, which should modify each element of the array Salary having N elements, as per the following rules:

Existing Salary Values Required Modification in Value
If less than 100000 Add 35% in the existing value
If >=100000 and <20000 Add 30% in the existing value
If >=200000 Add 20% in the existing value
CBSE12A-2016

03A-2015 2

Write the definition of a function Change(int P[], int N) in C++, which should change all the multiples of 10 in the array to 10 and rest of the elements as 1. For example, if an array of 10 integers is as follows:

 P[0] P[1] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9] 100 43 20 56 32 91 80 40 45 21

After executing the function, the array content should be changed as follows:

 P[0] P[1] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9] 10 1 10 1 1 1 10 10 1 1
CBSE12A-2015