0% found this document useful (0 votes)
23 views2 pages

Lab 3

Uploaded by

ltmthu07072005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Lab 3

Uploaded by

ltmthu07072005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Techniques Knowledge Engineering Department

Lab 3: Pointer
Complete the following given functions

1. Swap 2 given integers.

void swap(int* a, int* b)

2. Calculate the total value of 2 integers.

int* sum(int* a, int* b)

3. Input an array with an unknown size.

void inputArray(int* a, int &n)

4. Print a given array

void printArray(int* a, int n)

5. Find the largest value from a given array.

int* findMax(int* arr, int n)

6. Duplicate a given array.

int* copyArray(int* arr, int n)

7. Count even numbers from a given subarray. Generate a subarray with all even numbers from the given array.

int* countEvens(int* arr, int n, int* evens)

int* genEvenSubarray(int* arr, int n, int* count)

8. Find the subarray with the largest total value from a given array.

int* findLargestTotalSubarray(int* a, int n, int &total, int &length)

9. Find the longest ascending subarray from a given array.

int* findLongestAscendingSubarray(int* a, int n, int &length)

10. Swap 2 given arrays.

void swapArrays(int* a, int* b, int &na, int &nb)

Page 1 / 2
Programming Techniques Knowledge Engineering Department

11. Concatenate 2 given array.

int* concatenate2Arrays(int* a, int* b, int na, int nb)

12. Given 2 ascending arrays with distinguishing elements. Generate a new ascending array with all elements from the
given array.

int* merge2Arrays(int* a, int* b, int na, int nb, int&nc)

13. Generate a random matrix with keyboard input size.

void generateMatrix1(int** A, int &length, int &width)

14. Given 2 1D arrays a and b. Generate the matrix c that c[i][j] = a[i] * b[j].

int** generateMatrix2(int* a, int* b, int na, int nb)

15. Swap 2 columns/rows of a given matrix.

void swapRows(int** a, int length, int width)

void swapColumns(int** a, int length, int width)

16. Generate the transpose matrix of a given matrix.

int** transposeMatrix(int** a, int length, int width)

17. Concatenate 2 given size-equal matrices, horizontally / vertically.

int** concatenate2MatricesH(int** a, int** b, int length, int width)

int** concatenate2MatricesV(int** a, int** b, int length, int width)

18. Multiple 2 given matrices.

bool multiple2Matrices(int** a, int** b, int lengtha, int widtha, int lengthb, int widthb)

19. Given matrice a. Find the submatrix of a which satisfy keyboard input size and has the largest total value of its
elements.

int** findSubmatrix(int** a, int length, int width, int &length_, int &width_)

Page 2 / 2

You might also like