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>
#include<cmath>
#include<cstdlib>
#include<cstring>
#define MAX 100
using namespace std;

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 << endl;}
}

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 compute_matrixtranspose_matrix_product (int A[MAX][MAX], int m, int n, int ATA[MAX][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];
   }
  }
  
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] += AT[i][k]*A[k][j]; 
			} 
} 
} 

}

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

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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<simplecpp>
#define maxsize 100
void inparr(int a[][maxsize],int m, int n){
for (int i=0; i<m; i++){
for (int j=0; j<n; j++){
cout<<"enter row"<<i<<"enter coloumn"<<j<<"value";
cin>>a[i][j];
}
}cout<<endl;
}
void outarr(int a[][maxsize], int m,int n) {
for (int i=0; i<m;i++){
for (int j=0; j<n; j++){
cout<<a[i][j];
}cout<<endl;
}outarr(a,n,m);
}
void matrixmul (int a[][maxsize], int b[][maxsize], int m,int n){
int c[m][maxsize];
for(int i=0; i<m; i++){
for (int j=0; j<n; j++){
for (int k=0; k<n; k++){
 c[i][j] += a[i][k]*b[k][j];
}}cout<<endl;
}outarr (c,n,n);
}
main_program{
int m ;int n;
cin>>m>>n;
int a[m][maxsize], b[n][maxsize];
{
for (int i=0; i<m; i++){
for (int j=0; j<n; j++){
cin>>a[i][j];
b[j][i]=a[i][j];
}
}
outarr(b,n,m);
matrixmul (a,b,m,n);

}
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: B
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 500
void compute_matrixtranspose_matrix_product (int A[][MAX], int m, int n, int ATA[][MAX]){
	int c[MAX][MAX];
	for (int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			ATA[j][i]=A[i][j];
		}
	}
	for(int i=0; i<n;i++){
		for(int j=0; j<n; j++){
			c[i][j]=0;
			for (int k=0;k<m;k++){
				c[i][j]+=ATA[i][k]*A[k][j];
			}
		}
	}
	for (int i=0; i<n;i++){
		for (int j=0;j<n;j++){
			cout<<c[i][j];
			if (j<n-1) cout<<" ";
		}
		if (i<n-1) cout<<endl;
	}
}
void inputmatrix(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];
		}
	}
}
int main(){
	int m,n;
	cin>>m>>n;
	int A[MAX][MAX];
	int ATA[MAX][MAX];
	inputmatrix(A, m,n);
	compute_matrixtranspose_matrix_product(A, m, n, ATA);
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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;
int main(){
	int n;
	cin >> n;
	while (n!=0){
		if (n%10 != 0){
			cout << n%10;
		}
		n /= 10;
	}
	return 0;
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
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 print(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(j!=n-1) {cout<<" ";}
		}
		if(i!=m-1) {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];
			}
		}
	}
	print(ATA,n,n);
}
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: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 input_2D(int a[][8], int m, int n){
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++) {
            int x;
            cin>>x;
            a[i][j]=x;
        }
    }
}

void display_2D(int a[][8], 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 transpose_matrix(int a[][8], int b[][8], int m, int n){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            b[i][j]=a[j][i];
        }
    }
}

void product_2D(int a[][8], int m, int n, int ata[][8]){
    int i,j,k;
    int b[n][8];
    transpose_matrix(a,b,m,n);
    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]; 
			} 
  } 
 }
 display_2D(ata,n,n);
}

int main(){
    int m,n;
    cin>>m>>n;
    int a[m][8];
    input_2D(a,m,n);
    int ata[m][8];
    product_2D(a,m,n,ata);
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 A[][MAX], int m, int n, int ATA[][MAX]){
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ATA[j][i]=A[i][j];
		}
	}
	
}

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

	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>A[i][j];
		}
	}
	compute_matrixtranspose_matrix_product(A,n,m,ATA);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			result[i][j]=0;
			for(int k=0;k<m;k++){
				result[i][j]+=A[k][j]*ATA[i][k];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout<<result[i][j]<<' ';
		}cout<<endl;
	}
	return 0;
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 fillmat(int matrix[][100], int m, int n){
	int i=0, j=0;
	while(i<m){
		j=0;
		while(j<n){
			//cout<<"("<<i<<","<<j<<") : ";
			cin>>matrix[i][j];
			j=j+1;
		}
		i=i+1;
		//cout<<"\n";
	}
}

void printmat(int matrix[][100], int m, int n){
	int i=0, j=0; //cout<<"\n----------\n";
	while(i<m){
		j=0;
		while(j<n){
			cout<<matrix[i][j]<<" ";
			j=j+1;
		}
		i=i+1;
		cout<<"\n";
	}
	//cout<<"----------\n";
}

void transposemat(int matrix[][100], int transmatrix[][100], int m, int n){
	int i=0, j=0;
	while(i<m){
		j=0;
		while(j<n){
			transmatrix[j][i] = matrix[i][j];
			j=j+1;
		}
		i=i+1;
		//cout<<"\n";
	}
}

/*

void compute_matrixtranspose_matrix_product (int A[][max], int m, int n, int ATA[][max]){
	int i=0, j=0, k=0; int result[100][100]; int count=0;
	while(i<m){
		j=0;
		while(j<n){
			k=0;
			count = 0;
			while (k<n){
				count = ATA[i][k]*A[j][k] + count;
				k=k+1;
			}
			result[i][j] = count;
			j=j+1;
		}
		i=i+1;
	}
	printmat(result, n, n);
}*/

void compute_matrixtranspose_matrix_product (int A[][max], int m, int n, int ATA[][max]){
	int result[100][100]; int count=0;
	for (int i=0; i<n; i++){
		for (int j=0; j<n; j++){
			count=0;
			for (int k=0; k<m; k++){
				//cout<<"("<<i<<","<<k<<")"<<"+"<<"("<<k<<","<<j<<")\n";
				count = ATA[i][k]*A[k][j] + count;
			}
			result[i][j] = count;
			//cout<<endl;
		}
	}
	printmat(result, n, n);
}


int main(){

int m,n;
//cout<<"m : ";
cin>>m;
//cout<<"n : ";
cin>>n;

int mat[m][100]; int transmat[n][100];

fillmat(mat, m, n);
//printmat(mat, m , n);
transposemat(mat, transmat, m, n);
//printmat(transmat, n , m);
compute_matrixtranspose_matrix_product(mat, m , n, transmat);
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 mattransposematproduct (int A[MAX][MAX], int m, int n, int ATA[MAX][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];
}}}}
int main(){
int m,n;
int A[MAX][MAX],ATA[MAX][MAX];
cin>>m>>n;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>A[i][j];}}
mattransposematproduct(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: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 10
using namespace std;
void compute_matrixtranspose_matrix_product (int A[][MAX],int m,int n,int ATA[][MAX]) {
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>A[i][j]; 
}}
int AT[n][m];
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] = ATA[i][j] +( AT[i][k] * A[k][j]);
}}
}}
int main() {
int m,n;
cin>>m>>n;
int a[MAX][MAX];int b[MAX][MAX];
compute_matrixtranspose_matrix_product (a,m,n,b);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout << b[i][j]<< " ";
} cout << "\n";}
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 10
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];
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: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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<cmath>
#include<string.h>
using namespace std;

#define max 100

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

void print(int a[][max],int n1,int n2)
{
for(int i=0;i<n1;i++)
      {
      for(int j=0;j<n2;j++)
           {
           cout<<a[i][j]<<" ";
           }
      cout<<endl;
      }
}

void transpose(int a[][max],int atrans[][max],int n1,int n2)
{
for(int i=0;i<n1;i++)
      {
      for(int j=0;j<n2;j++)
          {
          atrans[j][i]=a[i][j];
          }
      }
}

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];
}}}}

int main(){
int m,n;
cin>>m>>n;
int a[m][max],b[n][max],c[n][max];
input(a,m,n);
transpose(a,b,m,n);
matrix_multiply(b,a,c,n,m,m,n);
print(c,n,n);
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: B
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[][10],int m,int n,int ATA[][10]){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int sum=0; 
 for(int k=0;k<m;k++){
 sum+= A[k][i]*A[k][j];
    } ATA[i][j]=sum;
   }
 }return;
}
int main(){
int m,n;
cin>>m>>n;
int A[m][10];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++)cin>>A[i][j];
}
int ATA[n][10];
compute_matrixtranspose_matrix_product(A,m,n,ATA);
for(int i=0;i<n;i++){
cout<<endl;
for(int j=0;j<n;j++)cout<<ATA[i][j]<<" ";
}
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 get2darr(int A[][MAX],int r,int c){
int i,j;
for(i=0;i<r;i++){
  for(j=0;j<c;j++){
     cin>>A[i][j];
}
}
}
void compute_matrixtranspose_matrix_product( int A[][MAX], int r, int c,int AtA[][MAX]){
      int B[MAX][MAX];
      
     for(int i=0;i<c;i++){
	for(int j=0;j<r;j++){
	   B[i][j]=A[j][i];
	}
    }
       for(int f=0;f<c;f++){
	  for(int k=0;k<c;k++){
           AtA[f][k]=0;
		for(int d=0;d<r;d++){
                   AtA[f][k]+=B[f][d]*A[d][k];
		} 
           }
       }


}
int main(){
int r,c;
cin>>r>>c;
int A[MAX][MAX];
int AtA [MAX][MAX];
get2darr(A,r,c);
compute_matrixtranspose_matrix_product ( A, r, c, AtA);
for(int i=0;i<c;i++){
   for(int j=0;j<c;j++){
      cout<<AtA[i][j]<<" ";
	}cout<<endl;
     }
}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A
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 at(int a[][100],int n1, int n2, int b[][100]){
for(int i=0;i<n1;i++){
for(int j=0;j<n2;j++){
b[j][i]=a[i][j];}}}

void compute_matrixtranspose_matrix_product(int a[][100], int n1, int n2, int b[][100], int c[][100]){
for(int i=0;i<n2;i++){
for(int j=0;j<n2;j++){
c[i][j]=0;
for(int k=0;k<n1;k++){
c[i][j]=c[i][j]+b[i][k]*a[k][j];}}}}

int main(){
int n1,n2;
cin>>n1>>n2;
int a[n1][100];
for(int i=0;i<n1;i++){
for(int j=0;j<n2;j++){
cin>>a[i][j];}}
int b[n2][100];
at(a,n1,n2,b);
int c[n2][100];
compute_matrixtranspose_matrix_product(a,n1,n2,b,c);
for(int i=0;i<n2;i++){
for(int j=0;j<n2;j++){
cout<<c[i][j]<<" ";} cout<<endl;}}

Grading criterion: Overall calculation is in the function.
Rating A: Function written as per given signature
Rating B: Function written but not as per signature, or some other partially wrong
Rating C: Not done in function
Rating D: 0
Assigned grade: A