Tuesday, 30 September 2014

WAP to add two matrix

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a[10][10],b[10][10],c[10][10];
int i,j,x,n;
printf("\t Enter the no. of row in Matrix ");
scanf("%d",&x);
printf("\n\t Enter the no. of column in Matrix ");
scanf("%d",&n);
printf("\n\t Enter the Matrix of A : ");
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\n\tEnter the Matrix of B : ");
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<x;i++){
for(j=0;j<n;j++) {
c[i][j]= a[i][j]+b[i][j];
}
}
printf("\n\t Addition is :  ");
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
printf("%d  ",c[i][j]);
}
printf("\n\t\t\t");
}
getch();
}

No comments:

Post a Comment

Please write your doubts