0% found this document useful (0 votes)
4 views

Lab Work 8.2 - C Language

ruwq
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)
4 views

Lab Work 8.2 - C Language

ruwq
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/ 4

C Language

Lab Work

Chapter - 8
Array in Detail

RED & WHITE MULTIMEDIA EDUCATION


Shaping “skills” for “scaling” higher…!!!

From the Headquarter of RNW


Surat, Gujarat, India
https://www.rnwmultimedia.edu.in
Lab Work #8.2

Sr. No. Question

Write a Program to find the average of a given 2D array.


For example,
Input:
Enter the array's row size: 3
Enter the array's column size: 3

Enter array's elements:


a[0][0] = 2
a[0][1] = 4
Q.1 a[0][2] = 1
a[1][0] = 3
a[1][1] = 5
a[1][2] = 4
a[2][0] = 8
a[2][1] = 2
a[2][2] = 6

Output:
Average of an Array: 3.88

Write a Program to perform the addition operation of two 2D arrays & store it in
another array. Keep in mind that both array sizes must be the same.
For example,
Input:
Enter the array's row size: 3
Enter the array's column size: 3

Enter array A's elements:


Q.2 a[0][0] = 2
a[0][1] = 4
a[0][2] = 1
a[1][0] = 3
a[1][1] = 5
a[1][2] = 4
a[2][0] = 8
a[2][1] = 2
a[2][2] = 6

Copyright © Red & White Education Pvt. Ltd. Page 2


Enter array B's elements:
b[0][0] = 3
b[0][1] = 6
b[0][2] = 2
b[1][0] = 5
b[1][1] = 6
b[1][2] = 8
b[2][0] = 3
b[2][1] = 7
b[2][2] = 4

Output:
Array C is:
5 10 3
8 11 12
11 9 10

Write a Program to find the sum of diagonal elements from a given 2D array.
For example,
Input:
Enter the array's row & column size: 3

Enter array's elements:


a[0][0] = 2
a[0][1] = 4
a[0][2] = 1
Q.3
a[1][0] = 3
a[1][1] = 5
a[1][2] = 4
a[2][0] = 8
a[2][1] = 2
a[2][2] = 6

Output:
The sum of diagonal elements of an Array: 13

Write a Program to print and find the sum of all boundary elements from a given 5x5
2D array.
Q.4
For example,
Input:

Copyright © Red & White Education Pvt. Ltd. Page 3


Enter array's elements:
a[0][0] = 2
a[0][1] = 4
a[0][2] = 1
a[0][3] = 6
a[0][4] = 3
a[1][0] = 9
a[1][1] = 5
a[1][2] = 4
a[1][3] = 6
a[1][4] = 7
a[2][0] = 8
a[2][1] = 2
a[2][2] = 6
a[2][3] = 3
a[2][4] = 5
a[3][0] = 3
a[3][1] = 4
a[3][2] = 8
a[3][3] = 5
a[3][4] = 1
a[4][0] = 2
a[4][1] = 3
a[4][2] = 9
a[4][3] = 5
a[4][4] = 7

Output:
24163
9 7
8 5
3 1
23957

The sum of boundary elements of an Array: 75

Copyright © Red & White Education Pvt. Ltd. Page 4

You might also like