You are on page 1of 2

Lab Tasks (1D + 2D Array)

Task 1
Write a program that reads two arrays from the user of the same size:
Lab_Marks: contains double numbers representing the students’ lab marks
Absences: contains integer numbers representing the total absences for each student.

The program then calls a function called (CalcTotal) that will take Lab_Marks
and Absences as an input and returns an array Result of type double that contains the result of
subtracting each element in Absences from the corresponding element in Lab_Marks

Prototype of the Function should be as:

Double* CalcTotal(double [], double [], int) .

Lab_Marks 78.0 90.0 55.5 85.7 99.0

Absences 5 3 2 0 3

Result 73.0 87.0 53.5 85.7 96.0

Task 2:
Write a C++ function which computes sum of two square matrices using two-dimensional array
in C++.

SAMPLE OUTPUT:
Enter matrix 1
1 2 3
4 5 6
1 2 3

Enter matrix 2
3 4 5
8 7 6
9 1 11
0

Sum of matrices is
4 6 8
12 11 12
10 12 14

Bonus Task:
Create an array of user defined size. Fill this array with random numbers (Auto Generated). Create a
menu from 1 to 6 to perform operation on array. As the option is selected.
1. Update array (Single indexed value)
2. Print the array
3. Find minimum
4. Find maximum
5. Search a number
6. Sort the array
7. Print the array in reverse order

Bonus Task:
Write a C++ program which computes product of two square matrices using two-dimensional
array in C++.

SAMPLE OUTPUT:
Enter matrix 1
1 2 3
4 5 6
7 8 9

Enter matrix 2
9 8 7
6 5 4
3 2 1

Product of matrix 1 and matrix 2 is


30 24 18
84 69 54
13 114 90
8

You might also like