After compiling of below program , i received the "ms with error".
Please help me.
Thank you,

#include<iostream.h>
void main()
{
int a[3][3],i,j,m,n,sum1=0,sum2=0,z;
cout<<"\n Enter the order of the matrices";
cin>>m>>n;
cout<<"\n Enter the elements of the matrices";
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
if(i==j)
sum1+=a[i][j];
}
for(i=0,j=n-1;i<m;i++,j--)
{
sum2+=a[i][j];
}
cout<<"\n The sum of diagonal elements="<<sum1;
cout<<"\n The sum of subdiagonal elements="<<sum2;
cin>>z;
}
Member Avatar for iamthwee

If m or n is more than 3 you have problems for starters.

And where are you prompting the user for input? If it is doing calculations on nothing to begin with you'll get garbage as your output.

void main should be int main.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.