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

College of Engineering & Technology: Department Lecturer Course Title Course Code Date

This document contains a class worksheet for a Programming Applications course taught by Dr. Hassan Abounaser during the Summer 2016-2017 term. The worksheet covers topics including: 1. Writing programs to perform operations on matrices such as addition, multiplication, and finding the transpose. 2. Identifying errors in code fragments involving 2D arrays. 3. Developing algorithms to analyze properties of square matrices like finding the sum of diagonal elements or number of non-zero elements. 4. Writing a complete program to input and output a 2x5 double array with row and column sums. 5. Designing functions for a tic-tac-toe game to initialize the board, check if

Uploaded by

adel nabhan
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)
71 views2 pages

College of Engineering & Technology: Department Lecturer Course Title Course Code Date

This document contains a class worksheet for a Programming Applications course taught by Dr. Hassan Abounaser during the Summer 2016-2017 term. The worksheet covers topics including: 1. Writing programs to perform operations on matrices such as addition, multiplication, and finding the transpose. 2. Identifying errors in code fragments involving 2D arrays. 3. Developing algorithms to analyze properties of square matrices like finding the sum of diagonal elements or number of non-zero elements. 4. Writing a complete program to input and output a 2x5 double array with row and column sums. 5. Designing functions for a tic-tac-toe game to initialize the board, check if

Uploaded by

adel nabhan
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

COLLEGE OF ENGINEERING & TECHNOLOGY

Department : Computer Engineering


Lecturer : Dr. Hassan Abounaser
Course Title : Programming Applications
Course Code : CC213
Date : Summer 2016-2017

SHEET (3): 2DA


Class Work:
1. Write a program to read a matrix (3×3), and print it on the screen.
2. Write a function to add two matrices and put the result in a third matrix.
3. Write a complete program that do the following tasks:
a. Read two matrices of size 4×4
b. Write a functions to add, multiply the two arrays and put the result in a third array
c. Write a function to get the transpose of a matrix
Home Work:
1. Write a program to read two matrices (3×3),
a. Prints their sum.
b. Prints the transpose of the first one.
c. Prints the determent of the second one.
d. Prints their multiplication.
2. What is wrong with the following code fragment?
int x, y;
int array[10][3];
main( )
{
for ( x = 0; x < 3; x++ )
for ( y = 0; y < 10; y++ )
array[x][y] = 0;
return 0;
}
3. Write a program that computes the sum of diagonal elements of a square matrix.
4. Let A be an N × N square matrix array. Write algorithms for the following:
a. Find the number of non-zero elements in A.
b. Find the product of the diagonal elements (a11, a22, a33,....,ann).

Page 1/2
5. Write a complete C program to ask the user for the elements of a 2x5 type double array
named array (input is to be entered row by row). Then display the sum of the values in each
row and of each column as follows for example
| Row Sum
1.0 2.5 3.0 4.5 0.5 | 11.5
2.0 3.0 1.0 1.5 2.0 | 9.5
______________________________|
Column Sum 3.0 5.5 4.0 6.0 2.5
6. In a tic-tac-toe game, the board can be represented by the array:
char board [3][3], where each cell can contain the value ‘X’, ‘O’, or ‘-‘ (where ‘-‘ represents
an empty cell). Assume that player X plays first.
a. Write a function that initializes the board for a new game.
b. Write a function that checks if the board is full or not.
c. Given the board of a game that hasn’t ended yet, write a function that determines
who’s turn is now. (Assume that player X plays first)
d. Write a function to check if ‘X’ is the winner.
e. Generalize the above function to check who is the winner
f. Write a complete working tic-tac-toe game.

GOOD LUCK ☺!

Page 2/2

You might also like