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

Lab 8 Tasks

The document outlines a lab assignment involving 2D arrays in programming. It includes tasks for initializing a 3x3 matrix with user input, performing matrix addition of two 3x3 matrices, and using a 2D character array to store and display names. Sample outputs are provided for each task to illustrate the expected results.

Uploaded by

Shahkaar Gul
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)
7 views2 pages

Lab 8 Tasks

The document outlines a lab assignment involving 2D arrays in programming. It includes tasks for initializing a 3x3 matrix with user input, performing matrix addition of two 3x3 matrices, and using a 2D character array to store and display names. Sample outputs are provided for each task to illustrate the expected results.

Uploaded by

Shahkaar Gul
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

Lab 8: 2d arrays

Task 1: Initialization and Input


• Write a program to declare a 2D array of size 3x3 and initialize it with
user input.
• Print the array in matrix form (row by row).

Sample Output

Enter elements for a 3x3 matrix:


1 2 3
4 5 6
7 8 9

Matrix:
1 2 3
4 5 6
7 8 9

Task 2: Matrix Addition


• Implement a program to add two 3x3 matrices.
• Take both matrices as input and display the resulting matrix.

Sample Output

Enter elements for Matrix 1:


Row 1: 1 2 3
Row 2: 4 5 6
Row 3: 7 8 9

Enter elements for Matrix 2:


Row 1: 9 8 7
Row 2: 6 5 4
Row 3: 3 2 1

Result Matrix:
10 10 10
10 10 10
10 10 10

1
Task 3: Use 2d char array to store names and display them
Sample Output

Enter 1 Name: name1


Enter 2 Name: name2
Enter 3 Name: name3
-------------------
name1
name2
name3

You might also like