#include<stdio.h> main() { int a[10][10],b[10][10],c[10][10],i,j,m,n,p,q; printf("enter the order of first matrix(m,n):"); scanf("%d %d",&m,&n); printf("enter the order of second matrix(p,q):"); scanf("%d %d",&p,&q); if(p!=m||q!=n) printf("addetion is not possible"); else { printf("enter the elements of first matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("enter elelmets(%d,%d)\n",i+1,j+1); scanf("%d",&a[i][j]); } } printf("\nenter the elemets of second matrix\n"); for(i=0;i<p;i++) { for(j=0;j<q;j++) { printf("enter elelmets of (%d,%d)",i+1,j+1); scanf("%d",&b[i][j]); } } printf("first matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("\t%d",a[i][j]); } printf("\n"); } printf("second matrix\n"); for(i=0;i<p;i++) { for(j=0;j<q;j++) { printf("\t%d",b[i][j]); c[i][j]=a[i][j]+b[i][j]; } printf("\n"); } printf("sum of matrix\n"); for(i=0;i<p;i++) { for(j=0;j<q;j++) printf("\t%d",c[i][j]); printf("\n"); } } }
Tuesday, 14 February 2012
how to add two matrix
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment