Let Us C (Chapter 8 : Arrays) : Program-13_1

(1) Write a program to add two 6 x 6 matrices.
let us c chapter 8 arrays problem 13_1


// Let Us C (Chapter 8 : Arrays) : Program-13_1
/* (1) Write a program to add two 6 x 6 matrices. */

#include<stdio.h>
#include<conio.h>
void main()
{
	int M1[6][6], M2[6][6], M3[6][6],i,j,k=1;
	clrscr();
	printf("\nProgram for Addition of Matrices");
	printf("\nEnter two 6 X 6 matrices");
	printf("\nEnter 36 elements of 1st Matrix separated by space\n");
	for(i=0;i<6;i++)
	{
		for(j=0;j<6;j++)
		{
			scanf("%d",&M1[i][j]);
		}
	}
	printf("\nEnter 36 elements of 2nd Matrix seprated by space\n");
	k=1;
	for(i=0;i<6;i++)
	{
		for(j=0;j<6;j++)
		{
		       //printf(" Enter Element %d : ",k++);
			scanf("%d",&M2[i][j]);
		}
	}
	printf("***** 1st Matrix *****\n");
	for(i=0;i<6;i++)
	{
		for(j=0;j<6;j++)
		{
			printf("%4d",M1[i][j]);
		}
		printf("\n");
	}
	printf("***** 2nd Matrix *****\n");
	for(i=0;i<6;i++)
	{
		for(j=0;j<6;j++)
		{
			printf("%4d",M2[i][j]);
		}
		printf("\n");
	}

	printf("\n******* Addition of Matrices ********\n");
	for(i=0;i<6;i++)
	{
		for(j=0;j<6;j++)
		{
			M3[i][j] = M1[i][j] + M2[i][j];
			printf("%4d",M3[i][j]);
		}
		printf("\n");
	}
}
OUTPUT
let us c chapter 8 arrays problem 13_1 output


Comments

Popular posts from this blog

Chapter 5 : Functions & Pointers (Let us C)

Let Us C (Chapter 8 : Arrays) : Program-9

Chapter 3: The Loop Control Structure (Let Us C)