```
//square matrix
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int main()
{ void diagsum(int a[10][10],int n);
void rowsum (int a[10][10],int n);
void colsum (int a[10][10],int n);
int a[10][10];
int n,opt;
cout<<" enter the size of matrix (say 4 for 4/4etc..) ";
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{cin>>a[j];
}
}
for(int k =0;k<n;k++)
{
for(int l=0;l<n;l++)
{cout<<a[k][l]<<"\t";
}
cout<<endl;
}
cout<< " enter 1 for diag sum , 2 for row sum , 3 for column sum ";
cin>>opt;
switch(opt)
{
case 1: diagsum(int a,int n);/* the compiler is showing error from here .it says - primary expression required before int */
getch();
break;
case 2: rowsum(int a, int n);
getch();
break;
case 3: colsum(int a, int n);
getch();
break;
default: cout<<" wrong option ";
}
}
void diagsum(int a[10][10],int n)
{
int diag1=0,diag2=0;
for(int i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
if(i==j)
{
diag1+=a[j];
}
if(i+j==n-1)
diag2+=a[j];
}
cout<<" diagonal 1 = "<<diag1;
cout<<"\n diagonal 2 = "<<diag2;
}
void rowsum (int a[10][10],int n)
{
int row,sum;
for(int i=0;i<n;i++)
{
for int j=0;j<n;j++)
{
sum+=a[j];
}
cout<<" sum of row "<<n<<" is "<<sum;
}
}
void colsum (int a[10][10],int n)
{
int col,sum;
for(int i=0;i<n;i++)
{
for int j=0;j<n;j++)
{
sum+=a[j];
}
cout<<" column of column "<<n<<" is "<<sum;
}
}
```