This is the first time I am using C++ and it seems like I am having some difficulties. My task has the following statement: 'If the number of rows and columns of the matrix X is the same (i.e. X is a square matrix), then find the scalar product of the elements of the main diagonal with the elements from random row K(K<=N).'
#include <iostream.h>
int main(){
int M,N,i,j;
int X[20][20];
do{cout<<"\n Vavedete stoinost za M:"<<endl;cin>>M;}
while(M<2||M>20);
do{cout<<"\n Vavedete stoinost za N:"<<endl;cin>>N;}
while(N<2||N>20);
for(i=0;i<M;i++)
for(j=0;j<N;j++)
{cout<<"\n Vavedete element ot X["<<i<<"]["<<j<<"]="<<endl;cin>>X[i][j];}
//usl.1.
int k;
if (i==j){
cout<<"\n ELementite na koi red da se umnojat s tezi na glavniq diagonal:"<<endl;cin>>k;
k=k-1;
int K[20];
for(i=0;i<M;i++)
for(j=0;j<M;j++){
int SP=1;
for(k=0;k<M;k++)
SP+=X[i][j]*X[k][j];
cout<<SP<<endl;}
return 0;}
}