You are on page 1of 2

Array Assignment (1 -Dimensional)

Part I
1. What is a one dimensional array ? what is its use
2. What do you mean by base address of a array
3. An array has its base address 4500 and each element occupies 4 bytes of memory .
find the address of the element at location B[35]
4. AN ARRAY A contains 10 elements another B contains 10 elements . transfer all the
elements of array A and B into array C
5. An array contains A contains 25 elements , another array B contains 7 elements .
Transfer all the elements of array B into C array and then transfer all the lements of
A at the back of array B and then display the content of C array.
6. Declare an array which stores 200 elements of values of real type
7. Write a loop to display all the 200 elements of the array
8. Write a UDF to count the number of negative elements in the array
9. Write a UDF to find the second biggest element in the array
10. Write a UDF to search for an element in the array
11. Write a function to reverse the array without using a second array
12. Write a UDF to transfer all the odd numbers to one array and all the even numbers to
another array
13. Write a UDF to transfer all the even numbers which are at the odd position in the array
to an array called even[] and rest of the elements into second array
14. Write functions for rearranging the elements in the order mentioned
{ 2, 5, 6, 7, 8 , 10 , 22, 14 ,27}
To
{ 10 22 14 27 8 2 5 6 7 }
15. Write a udf to replace all the elements of the array with 25 which are divisible by 2
and add 30 to all the elements which are divisible by 10
16. Write a udf to rearrange the elements in the following way
{ 2 3 4 5 6 7 8 9 10 12 }
to
{ 3 2 5 4 7 6 9 8 12 10
17. Write a udf to rearrange the following elements in the order specified
{ 1 2 3 4 5 6 7 8 9 10 }
to
{ 1 3 2 4 6 5 7 9 8 10 }

Continue page 2

Part II
1 Write a C++ program to find the sum and average of one dimensional integer array.
2 Write a C++ program to swap first and last element of an integer 1-d array.
3 Write a C++ program to find the largest and smallest element of an array.
Write C++ functions for all options. The functions should have two parameters name
of the array and number of elements in the array.
4 P is one-dimensional array of integers. Write a C++ function to efficiently search for
a data VAL from P. If VAL is present in the array then the function should return
value 1 and 0 otherwise.
5. write a udf to create an empty array input elements in the odd location of the array if the
numbers are divisible by 5 or put the numbers in the even location of the array and then display
the array elements
6. Write the output
int P[] = { 2 , 45, 67, 22, 80 , 34 , 56 , 78 , 21 , 1 , 11 , 82 , 100 , 4 };
int s = 25;
for ( int k = 0; k<11 ; k ++)
if ( k %2 ==0 )
s=s+P[k];
cout << s = << endl;

You might also like