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

Sheet08

Uploaded by

rizkomar6
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)
3 views2 pages

Sheet08

Uploaded by

rizkomar6
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

‫جامعة عين شمس‬

‫كليـة الهندسة‬
‫برامج الساعات المعتمدة‬

CSE122/CSE125/CSE131 Computer Programming


Sheet 8: 2D Arrays
______________________________________________________________

1- Write a program that reads 10 student names into array of strings


then prints them again as follows: -

Ahmed Said
Mark Munir
Mahi Hani
..

2- Write a program that sorts a list of names.

3- Write a program that adds and subtracts two 3x3 matrices, A and
B, and stores the results in C. You should implement the following
functions:

void addm(float A[][3], float B[][3] , float C[][3]);


void subm(float A[][3], float B[][3] , float C[][3]);

4- Write a function to print a matrix of size N × M, where N and M are


constant values.

5- Write a complete program that does the following tasks:


 Multiplying two matrices and put the result in a third one.
 Transposing a matrix.

6- Write a program that computes the sum of diagonal elements of a

1
square matrix.

7- Let A be an N × N square matrix array. Write algorithms for the


following:
 Find the number of non-zero elements in A.
 Find the product of the diagonal elements (a11, a22, a33,......ann).

8- Define a 100×100 2D array and fill it with random values between


1 and 1000, then search and count the number of values that
satisfy following condition:

All 8 neighbors’ values are less than the center value


⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯
⋯ 1 3 6 ⋯ ⋯ 2 9 9 ⋯
⋯ 3 7 5 ⋯ ⋯ 5 3 8 ⋯
⋯ 3 3 4 ⋯ ⋯ 6 4 7 ⋯
[⋯ ⋯ ⋯ ⋯ ⋯] [⋯ ⋯ ⋯ ⋯ ⋯]
Accepted Rejected

Hint: rand() function returns a random number from 0 to RAND_MAX.

_______________________________________

You might also like