#include<iostream.h>
#include<conio.h>
#define r 3
#define c 3
void main(){
int A[r][c],i,j,sum=0;
clrscr();
cout<<"Enter Elements of Matrix A"<<endl;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
cout<<"A["<<i<<"]"<<"["<<j<<"]=";
cin>>A[i][j];
if(i==j)
sum=sum+A[i][j];
}}
cout<<"Sum of diagonal elements of Matrix A is = "<<sum<<endl;
getch();
}
No comments:
Post a Comment