|
|
/*Program to print the sum of upper triangle and lower triangle in a matrix*/ #include<iostream.h> #include<conio.h> void main() { int a[3][3],rows,columns,b[3][3],k,l; clrscr(); for(int i=0;i<3;i++) { cout<<" "; for(int j=0;j<3;j++) { cout<<"Enter the "<<i+1<<" "<<j+1<<" element"; cin>>a[i][j]; } } for(k=0;k<3;k++) { for(l=0;l<3;l++) { b[k][l]=0; if(k==l) { b[k][l]+=a[k][l]; cout<<b[k][l]; } } } getch(); }
|