Q:

Write c program to add two matrix

0

Write c program to add two matrix

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

int rows,columns,c,d,first[10][10], second[10][10], sum[10][10];
printf ("Enter the no. of Rows and Columns of Matrix : ");
scanf("%d %d", &rows, &columns);
printf("Enter the element of first matrix \n");
	for(c=0;c<rows;c++)
		for(d=0;d<columns;d++)
		scanf("%d", &first[c][d]);
printf("Enter the element of second matrix \n");
	for(c=0;c<rows;c++)
		for(d=0;d<columns;d++)
		scanf("%d", &second[c][d]);
for(c=0;c<rows;c++)
for(d=0;d<columns;d++)
sum[c][d] =  first[c][d] + second[c][d];
	
printf("Sum of entered matrices are \n");
	for(c=0;c<rows;c++)
	{
for(d=0;d<columns;d++)
printf("%d \t", sum[c][d]);
printf("\n");
}
getch();

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now