Example #1
0
int main()
{

	int a[3][3];
	int b[3][3];
	int c[3][3];

	//Q2: define pointers (5)
	//Define pointers ap, bp, and cp to the matrices that are defined above

	//CODE HERE
	int *ap = a, *bp = b, *cp = c;
	

	//Uncomment these once you've defined your matrices

	initialize_matrices(ap, bp, cp);

	printf("Matrix a:\n");
	fill_matrix(ap);

	printf("Matrix b:\n");
	fill_matrix(bp);

	add_matrices(ap, bp, cp);

	print_sum_matrix(cp);

	

	return 0;
}
Example #2
0
int main()
{

	int a[3][3];
	int b[3][3];
	int c[3][3];

	//Q2: define pointers (5)
	//Define pointers ap, bp, and cp to the matrices that are defined above

	//SOLUTION CODE
	int* ap = &a[0][0];
	int* bp = &b[0][0];
	int* cp = &c[0][0];
	//SOLUTION CODE

	initialize_matrices(ap, bp, cp);

	printf("Matrix a:\n");
	fill_matrix(ap);

	printf("Matrix b:\n");
	fill_matrix(bp);

	add_matrices(ap, bp, cp);

	print_sum_matrix(cp);

	return 0;
}