Sie sind auf Seite 1von 3

Assignment (Computer Science) Topics-Array,Searching,Sorting,Merging)

Q1. Write a function to transfer the contents from array a1[] to two different arrays odd[] and even[] .The odd[] array should contain the values from odd positions of a1[] and even[] array should have values from even position of a1[]. The prototype is void getfrom (int a1[],int size,int odd[],int s1,int even[],int s2) Q2. Write a function to accept an integer array and its size as parameter and rearranges the array in reverse. The prototype is void reversearrray (int a[], int size) Q3. Write a function to accept an integer array and its size as arguments and replaces elements having even values with its half and elements having odd values with twice its vale. The prototype is void exchange(int a[],int size) Q4. Write a user defined function to search for an integer from array1 [] with the help of binary search method,returning an integer 0 to show absence of the number and integer 1 to show presence of the number in an array . The prototype of the function is int bsearch (int arr[],int size,int number) Q5. Write a function which accepts an array of integer and its size as parameters and divide all those array elements which are divisible by 2 by 8 and multiply other array elements by 3. The prototype of the function is void divide_arr( int a[],int size) Q6. Write a function which accepts an integer array and its size as parameter and exchanges the values of first half elements with the second half elements of the array. The prototype of the function is void exchange1(int a[],int size) Q7. Write a function to accept an integer two dimensional array and the size of row as well as column. The function should return the largest number element from the same array. The prototype of the array is int largest(int a[][6],int r,int c) Q8. Write a function to find the sum of each column of two dimensional integer array The prototype of function is void column_sum(int a[][5],int r,int c) Q9. Write a function to find the sum of each and every row of two dimensional integer array

The prototype of function is void row_sum(int a[][5],int r,int c)

Q10. Define a function swaparrray() to accept an integer array and its size as arguments . The function should rearrange the array in such a way that the values of alternate locations of the array are exchanged. The prototype of the function is void swaparray (int a[][5],int r,int c) Q11. Assume an array E containing elements of structure Employee is required to be arranged in descending order of salary .Write a function to arrange the same with the help of bubble sort ,the array and its size to be passed as parameters to function. Definition of structure Employee is as follows: Struct Employee { int eno; char name[25]; float salary;}; Student is required to write the whole program including main() to take inputs for array E and after execution of function it must display the sorted array Q12 . Assume an array E containing elements of structure Employee is required to be arranged in ascending order of salary .Write a function to arrange the same with the help of selection sort, the array and its size to be passed as parameters to function. Definition of structure Employee is as follows: struct Employee { int eno; char name[25]; float salary; }; Student is required to write the whole program including main() to take inputs for array E and after execution of function it must display the sorted array Q13.. Write a program to invoke and define a function void delete_element ( int a[], int , int)The parameters of function are 1. an integer array 2. size of an array 3. element to be deleted. All inputs are taken in main() and passed to the function. Display the array after the deletion. (The deleted element should be replaced by 0) Q14. Write a program to define and invoke a function void merge_sort(int a[],int s1,int b[],int s2).The parameters are array1-a[] sorted in ascending order ,array2-b[] sorted in ascending order , the function should merge two arrays in third array and should be sorted in ascending order.Students are required to write whole program, take inputs in main() and display the desired result.

Q15. Write a program to define and invoke a function void merge_sort(int a[],int s1,int b[],int s2)The parameters are array1-a[] sorted in ascending order ,array2-b[] sorted in descending order ,the function should merge two arrays in third array and should be sorted in ascending order.Students are required to write whole program, take inputs in main() and display the desired result.

Das könnte Ihnen auch gefallen