Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Université de Yaoundé I University of Yaounde I

ENSP NASI

Intensive computation, TD0 1 : basics on C, November 08th 2019


Prof Ndoundam Réne, Dr Messi Nguelé Thomas

Exercise 1. Reading from files, writing into files


1. Write a C function that reads elements of a matrix from a file, registers them in a
variable. The first line of this file contains the dimension of that matrix.
2. Write a C function that writes the elements of a matrix into a file.
Examples.
Input file 1 :
33
123
456
789
Input file 2 :
33
987
654
321

Exercise 2. Operations on matrices


1. Addition. Write a function that adds two matrices reading from files and then write
the result on another file. With the previous examples, the output file is as follows :
33
10 10 10
10 10 10
10 10 10

2. Substraction. Write a function that substracts two matrices reading from files and
then write the result on another file. With the previous examples, the output file is as
follows :
33
-8 -6 -4
-2 0 2
4 6 8
3. Multiplication. Write a function that multiplies two matrices reading from files and
then write the result on another file. With the previous examples, the output file is as
follows :
33
30 24 18
84 69 54
138 114 90
................ Good Luck ! ...............

You might also like