Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Faculty of Engineering
Mechatronics Department
Second Year
C Programming
Language
Arrays
HomeWork
Done by:
Osama Mohammed Mahyoub
(2017/162)
# This program prints the transpose of a matrix. It is obtained by
interchanging rows and columns of a matrix entered by the user.
This program can’t accept more than (5×5) matrix.
# Source Code:
# Output:
Valid values:
[2] × [3]
[5] × [2]
Invalid values:
When the number of rows or columns is more than 5, an error message
appears in the screen (Sorry! You can’t enter more than (5x5) matrix).
[5] × [8]
[9] × [6]
# Memory:
The entered values of the array are written and stored in the memory
over previous stored values, for example:
[3] × [2] matrix
The same operation takes place when storing the values of “in[][]” array
into the new “out[][]” array but in reversed indices of i & j.
# Flowchart: start
Read row
Read col
True
Print "\nSorry! You can't enter
i=1,j=1
more than (5x5) matrix."
end
False i <= row ?
i ++ , j++
j <= col ?
True
Read in[i-1][j-1]
1
1
i=0,j=0
True
Print “in[i][j] \t”
Print “\n”
i=0,j=0
True
Print “in[j][i] \t”
Print “\n”
end
out[i][j]=in[j][i]