Answer:
#include<iostream> 
using namespace std; 
 
double sumMajorDiagonal(double n,double sum); 
 
int main() 
{ 
int N; 
double a[10][10],n,sum=0; //declare and define matrix of size 10x10 
cout<<"Enter the size of the matrix: "; 
cin>>N; //input the size of the matrix 
if(N<2) //check condition wheather size of the matrix is greater than or equal to 2 
{ 
cout<<"Size of matrix must be 2 or more!"<<"\\"; 
return 0; 
} 
 
 
for(int i=0;i<N;i++) //loop for Row 
{ 
for(int j=0;j<N;j++) //loop for column 
{ 
cout<<"Enter element: "; 
cin>>n; //input the element in matrix 
a[i][j] = n; 
if(i==j) //check for major diagonal condition 
{ 
sum = sumMajorDiagonal(a[i][j],sum); //call sunMajorDiagonal funtion if condition statisfied 
} 
} 
} 
for(int i=0;i<N;i++) //loop for row 
{ 
for(int j=0;j<N;j++) //loop for column 
{ 
cout<<a[i][j]<<" "; //print elements of matrix 
} 
cout<<"\\"; //next line for new row 
} 
cout<<"Sum of the elements of major diagonal is: "<<sum<<"\\"; //print sum of the major row calculated 
} 
 
double sumMajorDiagonal(double n,double sum) 
{ 
return sum+n; //add the major diagonal elements and return the value 
}
Step-by-step explanation:
See attached image for output