Twelve Years of Service
Posts: 28
Threads: 13
C programmer?? 06-05-2014, 01:11 PM
#1
write a program in C to print out the entries along the diagonal of a matrix and the sum.
•
Thirteen Years of Service
Posts: 3,143
Threads: 100
RE: C programmer?? 06-05-2014, 02:43 PM
#2
Will we can't code the entire program for you but if you can provide us with the coding you've done maybe we'll be able to give you some headup
•
Thirteen Years of Service
Posts: 529
Threads: 52
RE: C programmer?? 06-05-2014, 05:01 PM
#3
I can give you the brief idea.
I hope you have already generated the following matrix by now[3x3 (m x m) for example].
[table]
[row]
[cell]a[0][0] [/cell]
[cell]a[0][1] [/cell]
[cell]a[0][2] [/cell]
[/row]
[row]
[cell]a[1][0] [/cell]
[cell]a[1][1] [/cell]
[cell]a[1][2] [/cell]
[/row]
[row]
[cell]a[2][0] [/cell]
[cell]a[2][1] [/cell]
[cell]a[2][2] [/cell]
[/row]
[/table]
i -> row and j -> column
The trick: print a[i][j] only when i=j or i+j==m-1
Hope you got it.
![[Image: MUJ8qSW.png]](http://i.imgur.com/MUJ8qSW.png)
-----------------------------------
Now learning:
Android Development, Java
Working on:
An FTP Client for Android
-----------------------------------
•