Home » NO IDEA » Addition of two matrix

Addition of two matrix

Blog Stats

  • 13,912 hits
December 2013
M T W T F S S
« Oct   Jan »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
//Develop a ‘C’ program to add two matrices
#include<stdio.h>
int main()
{
	int a[3][3],b[3][3],c[3][3]={{0,0,0},{0,0,0},{0,0,0}};
	int i ,j;
	printf("\n Enter the first 3*3 matrix");
	for(i=0;i<3;i++)
	for(j=0;j<3;j++)
	{
		scanf("%d",&a[i][j]);
	}
	printf("\n Enter the second matrix");
	for(i=0;i<3;i++)
	for(j=0;j<3;j++)
	{
		scanf("%d",&b[i][j]);
	}
	for(i=0;i<3;i++)
	for(j=0;j<3;j++)
	{
		c[i][j]=a[i][j]+b[i][j];
	}
	printf("\n The resultant matrix\n");
	for(i=0;i<3;i++)
	{
	for(j=0;j<3;j++)
	{
		printf("%d\t",c[i][j]);
	}
	printf("\n");
	}
	return 0;
	}
Advertisements

1 Comment

  1. […] write a c program for matrix addition […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: