WAP in C To Create A Matrix. Add The Diagonal Elements Of The Matrix
#include<stdio.h>
#include<conio.h> void main() { int a[3][3],trace=0,i,j; clrscr(); printf("\n enter the values of the matrix:\n"); for(i =0;i<3;i++) for (j=0;j<3;j++) scanf("%d",&a[i][j]); printf("\n the values of the matrix are :\n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%5d",a[i][j]); printf("\n"); } for (i=0;i<3;i++) trace+=a[i][j]; printf("The Summation Of The Diagonal Elements The matrix is %d",trace); getch(); } |