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

CENG205 Assignment1

The document provides instructions for an assignment to write a C program that multiplies two upper triangular matrices by reading values from an input file and outputting the result. The program should represent the matrices using 1D arrays, read values from an input file with a fixed name, multiply the matrices, and output the result as both a 1D array and 2D array.

Uploaded by

alimurattmercan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

CENG205 Assignment1

The document provides instructions for an assignment to write a C program that multiplies two upper triangular matrices by reading values from an input file and outputting the result. The program should represent the matrices using 1D arrays, read values from an input file with a fixed name, multiply the matrices, and output the result as both a 1D array and 2D array.

Uploaded by

alimurattmercan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

06.11.

2023

CENG205 DATA STRUCTURES


ASSIGNMENT 1

Write a C program for multiplication of two upper triangular matrices.

• Read an input file (with a fixed name of input.txt) that is located near your executable.
• Input file contains 3 lines of information:
o 1st line contains dimension (N) of triangular matrices that will be multiplied. Notice
that upper triangular matrices are square matrices of N x N.
o 2nd line contains content of first upper triangular matrix (matrix A) in a 1D array
form excluding zeros. Non-zero values in the matrix are separated with blank
characters.
o 3rd line contains content of first upper triangular matrix (matrix B) in a 1D array
form excluding zeros. Non-zero values in the matrix are separated with blank
characters.
• Example input file content:
4
1 2 3 4 6 7 8 11 12 16
16 15 14 13 11 10 9 6 5 1
• Example matrices given above can be demonstrated as:

1 2 3 4 16 15 14 13
𝐴 = [0 6 7 8 ] 𝐵=[0 11 10 9]
0 0 11 12 0 0 6 5
0 0 0 16 0 0 0 1

• Represent all of the triangular matrices using a 1D array structure, excluding zeros, in your
program. You are not allowed to use 2D arrays or any other data structure. You must
perform the multiplication using those 1D arrays.
• Result of the multiplication of the example matrices:

16 37 52 50
𝐶 =𝐴×𝐵 =[0 66 102 97]
0 0 66 67
0 0 0 16
06.11.2023

• Print the multiplication result as a 1D array in the same format of the input matrices and
also as a traditional matrix (2D array) in which values in each row are separated by tab (“\t”)
characters. Use a blank line between these two output forms.
• Example output of the above given matrices:
16 37 52 50 66 102 97 66 67 16

16 37 52 50
0 66 102 97
0 0 66 67
0 0 0 16

Matters needing attention:


• Submission file structure must conform the template given below:
< NameSurname_Studentnumber>.zip
|---*.c
(Name and surname information must be included in the file. Necessary information should
be written separately as a description line (comment line) in the code file submission.)
• Submissions should contain only the code files but not the executables or project files.
• Assignments confronting with these submission rules will be penalized.
• Assignments should be uploaded via Gazi LMS. No other submission methods (e-mail,
message) will be accepted.
• Assignments must be submitted on time. No late submissions will be accepted.
• Codes in assignments should be written in standard C programming language. Code::Blocks
IDE with GCC will be used for evaluation and it is your responsibility to be sure your code
works properly on this setup.
• Assignments should be prepared in English.
• Coding standards should be followed, and full attention should be paid to details such as
indentation, variable/function naming. It should be detailed with comment lines.
• All external ideas, algorithms and codes must be referenced properly as comment in the
code. Otherwise, assignments will be considered as copies.
• Sloppy or copy-paste assignments will be penalized.
• Must no copy, zero will be given when a copy is detected.
(Assignments will be subject to pairwise code comparison and similar assignments will be
considered as copies.)

You might also like