ASSIGNMENT-7
(Array one dimensional)
Q1. Write a program in C++, which should reposition the
content after swapping each adjacent pair of numbers in it.
Q2. Write a program in C++, to add 1 in all the odd values
and 2 in all the even values of the array T.
Q3. Program in c++, which repositions all the elements of the
array by shifting each of them one to one position before and by shifting the
first element to the last position.
Q4. Program in c++, which re-positions all the elements of
the array by shifting each of them to the next position and by shifting the
last element to the first position.
Q5. Write a program in C++, Given two arrays A and B. Array
‘A’ contains all the elements of ‘B’ but one more element extra. Write a c++
function which accepts array A and B and its size as arguments/ parameters and
find out the extra element in Array A. (Restriction: array elements are not in
order)
Example : - If Array A is {14, 21, 5, 19, 8, 4, 23, 11} and Array B is {23, 8, 19, 4, 14, 11, 5 } Then output will be 21 (extra element in Array A)
Example : - If Array A is {14, 21, 5, 19, 8, 4, 23, 11} and Array B is {23, 8, 19, 4, 14, 11, 5 } Then output will be 21 (extra element in Array A)
Q6. Write a program in C++, to arrange all the negative and
positive numbers from left to right.
Example : - If an array of 10 elements initially contains { 4,5,6,-7,8,-2,-10,1,13,-20} . Then the function rearrange them in following manner { -20,-10,-7,-2 1,4,5,6,8,13}
Example : - If an array of 10 elements initially contains { 4,5,6,-7,8,-2,-10,1,13,-20} . Then the function rearrange them in following manner { -20,-10,-7,-2 1,4,5,6,8,13}
Q7. Write a
program in C++,which
accepts a integer array and its size as an arguments and prints the output
(using nested loops) in following format :
Example : if the array is having1 2 4 5 7. Then the output should be
Example : if the array is having1 2 4 5 7. Then the output should be
1
2 2
4 4 4 4
5 5 5 5 5
7 7 7 7 7 7 7
2 2
4 4 4 4
5 5 5 5 5
7 7 7 7 7 7 7
Q8. Write
a program in C++, which finds the locations and values of largest and second
largest
Q13. Write a program in C++, which should modify each
element of the array Pay having N elements, as per the following rules: