CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>

#define MAX 100
using namespace std;
void input(int A[MAX][MAX], int m, int n)
{
for( int i=0;i<m;i++)
{
	for(int j=0;j<n;j++)
	{
	cin>>A[i][j];
	}
}
}

void output(int A[MAX][MAX], int m, int n)
{
for( int i=0;i<m;i++)
{
	for(int j=0;j<n;j++)
	{
	cout<<A[i][j];
	cout<<" ";
	}
      cout<<endl;
}
}

void transpose(int A[MAX][MAX], int AT[MAX][MAX], int m,int n)
{
for( int i=0;i<n;i++)
{
	for(int j=0;j<m;j++)
	{
	AT[i][j]=A[j][i];
	}
}
}

void compute_matrixtranspose_matrix_product (int A[MAX][MAX], int m, int n, int ATA[MAX][MAX])
{
int AT[MAX][MAX];
int i,j,k;
for( i=0;i<n;i++)
{
        for( j=0;j<m;j++)
        {
        AT[i][j]=A[j][i];
        }
}
for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
	ATA[i][j]=0;
		for(int k=0;k<m;k++)
		{
		ATA[i][j] += AT[i][k]*A[k][j];
		}
		
	}
}
}

int main()
{
int m,n;
cin>>m>>n;
int A[MAX][MAX];
int AT[MAX][MAX];
int ATA[MAX][MAX];
input(A,m,n);
compute_matrixtranspose_matrix_product (A, m, n, ATA);
output(ATA,n,n);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
using namespace std;
#define MAX 100 
void compute_matrixtranspose_matrix_product(int AB[][MAX], int m, int n, int ATA[][MAX]){
 int AT[MAX][MAX];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
AT[j][i]=AB[i][j];}
}
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++){
                        ATA[i][j] = 0;
        for(int k=0;k<m;k++){
                        ATA[i][j] += AT[i][k]*AB[k][j];
                        }
}
}
        for(int i=0;i<n;i++){
                for(int j=0; j<n; j++){
                        cout<<ATA[i][j]<<" ";
                } cout<<endl;
        }
}
int main(){
        int m; int n;  cin>>m>>n;
        int AB[MAX][MAX];int ATA[MAX][MAX];
        for(int i=0;i<m;i++){
                for(int j=0; j<n; j++){
                        cin>>AB[i][j];
                }
        }
        compute_matrixtranspose_matrix_product(AB,m,n,ATA);

        return 0;
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define MAX 100
using namespace std;
void compute_matrixtranspose_matrix_product(int A[][MAX], int m, int n, int R[][MAX]){
int B[n][m];
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
		B[j][i]=A[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
		R[i][j]=0;
		for(int k=0; k<m; k++){
		R[i][j]=R[i][j]+B[i][k]*A[k][j];
		}
		}
	}
	return;
}
int main(){
int m,n;
cin>>m>>n;
int A[m][100];
int R[n][100];
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
		cin>>A[i][j];
		}
	}
compute_matrixtranspose_matrix_product(A, m, n, R);
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
		cout<<R[i][j]<<" ";
		}
	cout<<endl;
	}
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define MAX 100
using namespace std;
void input(int A[][MAX],int m, int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin >> A[i][j];
}
}
}
void compute_matrixtranspose_matrix_product(int A[][MAX],int m, int n)
{
int At[MAX][MAX], AAt[MAX][MAX];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
At[i][j]=A[j][i];
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
AAt[i][j]=0;
for(int k=0;k<m;k++)
{
AAt[i][j]=AAt[i][j]+A[i][k]*At[k][j];
}
}
}
}
int main()
{
int n,m;
int A[MAX][MAX];
int At[MAX][MAX];
int AAt[MAX][MAX];
cin >> m >> n;
input( A, m,  n);
compute_matrixtranspose_matrix_product(A, m, n);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cout << AAt[i][j] << " ";
}
cout << '\n';
}
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
using namespace std;
#define MAX 9
void compute_matrixtranspose_matrix_product(int A[][MAX],int m,int n,int ATA[][MAX]){
	//first we will find transpose
	int AT[n][MAX];
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			AT[j][i]=A[i][j];
			}
		}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ATA[i][j]=0;
			for(int k=0;k<m;k++){
				int x=AT[i][k]*A[k][j];
				ATA[i][j]=ATA[i][j]+x;
				}
			}
		}
	}
void input(int A[][MAX],int m,int n){
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>A[i][j];
			}
		}
	}
void output(int A[][MAX],int m,int n){
	for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                        cout<<A[i][j]<<' ';
                        }
		cout<<endl;
                }
	}
int main(){
int m,n;
cin>>m;cin>>n;
int A[m][MAX],ATA[n][MAX];
input(A,m,n);
compute_matrixtranspose_matrix_product(A,m,n,ATA);
output(ATA,n,n);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define MAX 8
using namespace std;

void input_matrix(int A[][MAX], int m, int n)
{
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			cin>> A[i][j];
		}
	}
}

void print_matrix(int A[][MAX], int m, int n)
{
	for(int i=0; i<m; i++){
		for(int j=0; j<n; j++){
			cout<< A[i][j];
			if(!(i==m-1 && j==n-1)) cout<< " ";
		}
		cout<< endl;
	}
}

void compute_matrixtranspose_matrix_product(int A[][MAX], int m, int n, int ATA[][MAX])
{
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			ATA[i][j] = 0;
			for(int k=0; k<m; k++){
				ATA[i][j] += A[k][i]*A[k][j];
			}
		}
	}
}

int main()
{
	int m, n; cin>> m >> n;
	int A[MAX][MAX]; int ATA[MAX][MAX];
	input_matrix(A,m,n);
	compute_matrixtranspose_matrix_product(A,m,n,ATA);
	print_matrix(ATA,n,n);	
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define MAX 100
using namespace std;
void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]){
int AT[MAX][MAX];
for (int i=0; i < m; i++){
for (int j=0; j < n; j++){
AT[j][i] = A[i][j];
}}
for (int i=0; i < n; i++){
for (int k=0; k < n; k++){
for (int j=0; j < m; j++){
ATA[i][k] = ATA[i][k] + AT[i][j]*A[j][k];
}}}
for (int i=0; i <n; i++){
for (int j=0; j < n; j++){
cout << ATA[i][j] << " ";
}
cout << endl;
}
}
int main(){
int m,n;
cin >> m >> n;
int A[MAX][MAX];
for (int a=0; a<m; a++){
for (int b=0; b< n; b++){
cin >> A[a][b];
}}
int ATA[MAX][MAX];
for (int a=0; a<n; a++){
for (int b=0; b< n; b++){
ATA[a][b] = 0;
}}
compute_matrixtranspose_matrix_product(A, m, n, ATA);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define MAX 100
using namespace std;
void transpose(int A[][MAX], int A_T[][MAX], int n1, int n2){
    for (int i=0; i<n1;i++){
        for (int j=0;j<n2;j++){
            A_T[j][i]=A[i][j];
        }
    }
}
void matrix_multiply (int A[][MAX], int B[][MAX], int **C, int nr1, int nc1, int nr2, int nc2){
if (nc1 != nr2) { cout << "dimension mismatch"; return;}
int i,j,k;
for(i=0;i<nr1;i++) {
for(j=0;j<nc2;j++){
			C[i][j] = 0;
	for(k=0;k<nc1;k++){
			C[i][j] += A[i][k]*B[k][j];
			} 
} 
}
}
void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]){
    transpose(A,ATA,m,n);
    int **C=new int*[n];
    for (int i=0;i<n;i++){
        C[i]=new int[n];
    }
    matrix_multiply(ATA,A,C,n,m,m,n);
    for (int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<C[i][j]<<" ";
        }
        cout<<endl;
    }
    for (int i=0;i<n;i++){
        delete []C[i];
    }
    delete []C;
}
int main(){
    int m,n;
    cin>>m>>n;
    int A[MAX][MAX];
    for (int i=0;i<m;i++){
        for (int j=0;j<n;j++){
            cin>>A[i][j];
        }
    }
    int ATA[MAX][MAX];
    compute_matrixtranspose_matrix_product(A,m,n,ATA);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#include<cstring>
using namespace std;
void compute_matrixtranspose_matrix_product (int A[][100], int m, int n, int ATA[][100])
  {for (int i=0;i<n;i++)
    {for(int j=0;j<n;j++){
    ATA[i][j]=0;
    
    for(int k=0;k<m;k++){
        ATA[i][j]=ATA[i][j]+A[k][j]*A[k][i];}
        }
        }
        }
    
 
  int main()
  {int m,n;
 
    
    cin>>m>>n;
    int A[100][100];
    for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
    
    cin>>A[i][j];}
    }
    int ATA[100][100];
   compute_matrixtranspose_matrix_product (A,m,n,ATA);  
   for(int i=0;i<n;i++){
   {for(int j=0;j<n;j++)
   cout<<ATA[i][j]<<" ";
   }
   cout<<endl;
   }
   }

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
using namespace std;
#define MAX 100

void input (int A[][MAX], int n1, int n2){
int i,j;
for(i=0;i<n1;i++){
                for(j=0;j<n2;j++){
                        cin >> A[i][j];
                }
}
}

void output (int A[][MAX], int n1, int n2){
int i,j;
for(i=0;i<n1;i++){
                for(j=0;j<n2;j++){
                        cout << A[i][j] << " ";
                }
                cout << endl;
}
}

void matrix_multiply (int A[][MAX], int B[][MAX], int C[][MAX], int nr1, int nc1, int nr2, int nc2){
if (nc1 != nr2) { cout <<"dimension mismatch"; return;}
int i,j,k;
for(i=0;i<nr1;i++) {
for(j=0;j<nc2;j++){
			C[i][j] = 0;
	for(k=0;k<nc1;k++){
			C[i][j] += A[i][k]*B[k][j];
			}
}
}
}

void transpose (int A[][MAX], int AT[][MAX], int n1, int n2){
for (int i=0; i<n2; i++){
for (int j=0; j<n1; j++){
AT[i][j] = A[j][i];}}
}

void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]){
int B[MAX][MAX];
transpose(A,B,m,n);
matrix_multiply(B,A,ATA,n,m,m,n);
output(ATA,n,n);
}

int main(){
int m,n;
cin>>m>>n;
int A[MAX][MAX], ATA[MAX][MAX];
input(A,m,n);
compute_matrixtranspose_matrix_product(A,m,n,ATA);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define MAX 100
using namespace std;
void inp (int A[][MAX], int m, int n)
{
 for (int i = 0; i < m; i++)
 {
  for (int j = 0; j < n; j++) cin>>A[i][j];
 }
}
void opt (int A[][MAX], int m, int n)
{
 for (int i = 0; i < m; i++)
 {
  for (int j = 0; j < n; j++) cout<<A[i][j]<<" ";
  cout<<endl;
 }
}
void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX])
{
 int AT[MAX][MAX];
 for (int i = 0; i < m; i++)
 {
  for (int j = 0; j < n; j++) AT[j][i] = A[i][j];
 }
 for (int i = 0; i < n; i++)
 {
  for (int j = 0; j < n; j++)
  {
   ATA[i][j] = 0;
   for (int k = 0; k < m; k++)
   {
    ATA[i][j] += AT[i][k]*A[k][j];
   }
  }
 }
}
int main()
{
 int m, n;
 cin>>m>>n;
 int A[MAX][MAX];
 int ATA[MAX][MAX];
 inp (A, m, n);
 compute_matrixtranspose_matrix_product (A, m, n, ATA);
 opt (ATA, n, n);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define max 100
using namespace std;
void compute_matrixtranspose_matrix_product(int A[][max],int m,int n,int ATA[][max]){
int b[n][m];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
b[j][i]=A[i][j];}
}
int i,j,k;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
ATA[i][j]=0;
for(k=0;k<m;k++){
ATA[i][j]+=b[i][k]*A[k][j];
}
}}
for(int s=0;s<n;s++){
for(int t=0;t<n;t++){
cout<<ATA[s][t]<<" ";}
cout<<endl;
}
}
int main(){
int m,n;
cin>>m>>n;
int A[max][max];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>A[i][j];}}
int ATA[max][max];
compute_matrixtranspose_matrix_product(A,m,n,ATA);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
using namespace std;


void compute_matrixtranspose_matrix_product (int a[][100], int m, int n, int ata[][100]){
int at[100][100],b;
b=0;
for(int y=0;y<m;y++){for(int j=0;j<n;j++){at[j][y]=a[y][j];}}
for(int i=0;i<n;i++){for(int j=0;j<n;j++){for(int k=0;k<m;k++){
					b=b+at[i][k]*a[k][j];
				}ata[i][j]=b;
				  b=0;
		}
	}

//for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<at[i][j];
  //              }cout<<endl;}
}








int main (){

	int m,n;
	int a[100][100],ata[100][100];
	cin>>m>>n;
for(int i=0;i<m;i++){for(int j=0;j<n;j++){cin>>a[i][j];}}
compute_matrixtranspose_matrix_product(a,m,n,ata);
for(int i=0;i<n;i++){for(int j=0;j<n;j++){cout<<ata[i][j]<<" ";
		}cout<<endl;
	}
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
#define max 100
using namespace std;
void input_array_values(int A[][max],int m,int n){
 for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cin>>A[i][j];} } }
void compute_matrixtranspose_matrix_product(int A[][max],int m,int n,int ATA[][max]){
int AT[max][max];
 for(int i=0;i<n;i++){for(int j=0;j<m;j++){ AT[i][j]=A[j][i];} } 
for(int i=0;i<n;i++){for(int j=0;j<n;j++){ ATA[i][j]=0; for(int k=0;k<m;k++) { ATA[i][j]+=AT[i][k]*A[k][j];} } }
for(int i=0;i<n;i++){for(int j=0;j<n;j++){cout<<ATA[i][j]<<" ";} cout<<'\n';}
}
int main(){
int m,n;
cin>>m>>n;
int A[max][max],ATA[max][max];
input_array_values(A,m,n);
compute_matrixtranspose_matrix_product(A,m,n,ATA);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include <iostream>
using namespace std;
const int maxim=8;
void compute_transposematrix_matrix_product(int A[maxim][maxim],int m,int n,int ata[maxim][maxim])
{
 int B[maxim][maxim];
 for(int i=0;i<n;i++)
 for(int j=0;j<m;j++)
 B[i][j]=A[j][i];
 for(int i=0;i<n;i++)
 {
    for(int j=0;j<n;j++)
    {
        ata[i][j]=0;
        for(int k=0;k<m;k++)
        {
              ata[i][j]+=B[i][k]*A[k][j];
        }
    }
 }
}
void print_matrix(int ata[maxim][maxim],int n)
{
 for(int i=0;i<n;i++)
 {
   for(int j=0;j<n;j++)
   {
     cout<<ata[i][j]<<" ";
   }
   cout<<endl;
 }
}
int main(){
int m,n;
int A[maxim][maxim],B[maxim][maxim],ata[maxim][maxim];
cin>>m>>n;
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
cin>>A[i][j];
compute_transposematrix_matrix_product(A,m,n,ata);
print_matrix(ata,n);
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the dimensions of a matrix (m,n) as input from the user. The program should then take the matrix (let us call it A) itself as input from the user. Following this, the program should compute the product of the transpose of A with A (i.e. ATA of size n x n) and display the result. To accomplish this task, write a function of the form void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]).

Constraints
n is a positive integer, m,n <= 8

Student submission:
#include<iostream>
using namespace std;
#define Max 1000

void compute_matrixtranspose_matrix_product(int A[][Max],int m,int n,int ATA[][Max]){
for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
     ATA[i][j]=0;
    for(int k=0;k<m;k++){
      ATA[i][j]=ATA[i][j]+A[k][i]*A[k][j];
    }
  }
}
}

void f(){
int n,m;
cin>>m>>n;
int A[m][Max];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>A[i][j];}}
int ATA[n][Max];

compute_matrixtranspose_matrix_product(A,m,n,ATA);

for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
   cout<<ATA[i][j]<<" ";
  }
  cout<<endl;
}
}

int main(){
f();
return 0;
}

Grading criterion: quality and number of comments
Rating A: Well commented
Rating B: okay commented
Rating C: poor or no comments
Rating D: 0
Assigned grade: C