Академический Документы
Профессиональный Документы
Культура Документы
For e.g:
2 6 9 10 12 15
2 4 6 9 10 11 12 15
Write a program to delete the given elements in appropriate position
after creating 1 D array. Array should be in sorted order(ascending
order). Max size of an array is 50.
For e.g:
2 6 9 10 12 15
2 6 0 10 12 15
2 6 10 12 15
Passing Array and size as arguments
1) Print the numbers and sum of numbers whose
unit place is 2.
e.g: if an array is 12, 3, 2, 32, 25 then
output is : 12 , 2, 32 and sum =12+2+32 = 46
2) Given an array named A with following
elements:
3, -5, 1, 3, 7, 0, -15, 3, -7, -8
Write a C++ function to shift all the negative to left
so that the resultant array look like:
-5, -15, -7, -8, 3, 1, 3, 7, 0, 3
3) Write a function CHANGE( ) in C++, which accepts an array
of integer and its size as parameters and divide all those array
elements by 7 which are divisible by 7 and multiply other array
elements by 3.
Sample Input Date of the array
A[O] A[1] A[2] A[3] A[4]
21 12 35 42 18
Content of the array after calling CHANGE( ) function
A[O] A[1] A[2] A[3] A[4]
3 36 5 6 54
4) Write a function in C++ which accepts an integer array and its
size as arguments and replaces elements having odd values with
thrice its value and elements having even values with twice its
value.
Example : if an array of five elements initially contains the
elements as
3, 4, 5, 16, 9
then the function should rearrange the content of the array as
9, 8, 15, 32, 27
Quest) Write a function swaptobest( ) in C++ which accepts an
integer array and its size as arguments to modify the content of
the array in such a way that the elements which are multiples of
10 swap with the value present in the very next position in the
array.
e.g: if input array is :90, 56,45,20,34,54
then output array is: 56,90,45,34,20,54
- All odd numbers of A from left to right are copied into C from right to
left.
- All even numbers of B from left to right are copied into C from left to
right.
- All old numbers of B from left to right are copied into C from right to
left.
30 36 42
66 81 96
1. All row elements except the 1st element replaced by the 1st element,
2. All row elements except the 1st & 2nd element replaced by the 2nd element,
3. All row elements except the 1st, 2nd & 3rd element replaced by the 3rd element and so on.
For example: if initially the array was:-
5 6 10 2
2 6 9 12
18 14 5 6
Then, the contents of the array after execution of the above function will be:-
5 5 5 5
2 6 6 6
18 14 5 5