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.

Compute the Result by subtracting Absences from the corresponding element in Lab_Marks

Sample output is here:

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++ program which computes sum of two square matrices using two-dimensional array.

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
Task 3:
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, it calls a function with
appropriate parameters and return type.
1. Update array (Overload the function for both: Single value and complete array)
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 sum 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