 CPP All : Arrays Concepts and 1-D Arrays Concept Learning Code Sheets #### Preparing basic arrays #1593

Here we shall prepare some basic arrays of integers, fractions, characters and strings. #### Largest number in integer array #1610

Traversing an integer array linearly to find the largest number in the array. #### Char array variations #1623

Learning character array variations and need for null terminator

#### Linear search in array for search term presence and location #1630

Search for presence of element in an integer array for search term presence and location of element where it is found first.

#### Finding count of members in a linear array #2502

Finding the number of members in an array using the sizeof operator

#### Reversing an array #2506

Reversing an integer array using the swapping of members around midpoint.

#### Collecting array entries and displaying it like its formal representation #2510

Taking array entries from the user and displaying it like its formal representation as {1,2,..5}

#### Copying an Integer Array #3091

Demonstrating how an array can be copied to another array of same size by copying each member of the array.

#### printing filtered array content #3095

Demonstrating how to print the filtered array content.

#### copying filtered array content to another array #3102

Demonstrating how to filter the array content and then copy it to another array.

#### copying filtered array content to another array by maintaining count #3106

Demonstrating how to filter the array content and then copy it to another array by maintaining the filter size count.

#### Linear search using array reference passing to function #1628

Search for presence of element in an integer array by using a function with a call by reference of array, size and search term.

Exam Papers Problems #### 03A #5652

( As In Exam - CBSE12A-2016 )

Write the definition of a function FixSalary(float Salary[], int N) in C++, w

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

#### 03A #5764

( As In Exam - CBSE12A-2017 )

Write the definition of a function AddUp(int Arr[], int N) in C++, in which a

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.

#### 03A #5871

( As In Exam - CBSE12D-2015 )

Write the definition of a function Alter(int A[], int N) in C++, which should

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 A A A A A A A A A 55 43 20 16 39 90 83 40 48 25

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

 A A A A A A A A A A 5 0 5 0 0 5 0 5 0 5

#### 03A-2015 #5957

( As In Exam - CBSE12A-2015 )

Write the definition of a function Change(int P[], int N) in C++, which shoul

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 P P P P P P P P P 100 43 20 56 32 91 80 40 45 21

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

 P P P P P P P P P P 10 1 10 1 1 1 10 10 1 1

#### 01E #6016

( As In Exam - CBSE12D-2017 )

Find and write the output of the following C++ program code:
Note: Assu

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]<<"#";
}```

#### 03A #6032

( As In Exam - CBSE12D-2017 )

Write the definition of a function Reverse(int Arr[], int N) in C++, which sh

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.

#### Value modification function of 1 D array using slab based conditions #6165

( As In Exam - CBSE12D-2016 )

Write the definition of a function FixPay(float Pay[], int N) in C++, which s

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
Solved Problems #### Linear search function for search term presence and location #1632

Write a function linsearch(int [],int, int) which searches for the term 23 in

Write a function linsearch(int [],int, int) which searches for the term 23 in the given integer array [12,19,23,3,2] and returns its position in the array. This array should be initialised in the calling function and then passed as reference to the given function. Show implementation also.

#### Average of temperature values stored in array #2487

Write a program to store 10 temperature readings in an array and then find th

Write a program to store 10 temperature readings in an array and then find the average temperature of the given readings.

#### Proving palindrome array #2848

Write a program to prove that the give array [23,43,51,43,23] is a palindrome

Write a program to prove that the give array [23,43,51,43,23] is a palindrome array, means that its reversed pattern will be same as its original pattern.

#### Sum of integer array #3088

Write a program to collect 5 integer values from user in an integer array an

Write a program to collect 5 integer values from user in an integer array and then pass this array to a function along with its size. Return the sum of the array members from the function and print its value in the main routine.

#### Average value of array and members more than average #3098

Prepare an array of temperature readings of an entire week with data as

Prepare an array of temperature readings of an entire week with data as
25.3, 27.0, 24.8, 26.9, 25.9, 26.4, 24.0. Now find out the average temperature of the week and then print out the readings which are more than the average temperature.

#### Filling integer array members based on user input and summing them #5370

Write a program to collect 5 numbers from user into a 1-D integer array. Calc

Write a program to collect 5 numbers from user into a 1-D integer array. Calculate sum of all the input numbers and print it with a suitable message.

#### Searching elements from one array into another array #5617

Write a program to search members of integer array 1 in array 2 and print the

Write a program to search members of integer array 1 in array 2 and print the members of array 1 that are also found in array 1. Also print the total number of members found.
For e.g. if array 1 is [12,19,23,3,2] and array 2 is [13,12,2,3,14,21],
the output would be
12 3 2
count = 3

Code Sheets:12  Exam Paper Problems:7  Solved Problems:7
×