#include //conio.h #include //stdio.h
void input(int [][],int ,int); void output(int [][],int,int); void add(int [][],int [][],int,int); void diff(int [][],int [][],int,int); void multi(int [][],int [][],int,int,int);
void main() { int a[10][10],b[10][10]; int ma,na,mb,nb; int i,j,ch; char yn; clrscr(); flushall(); do { clrscr(); printf("\n\n\n\t\t\t\tOperations!!!"); printf("\n\n\t\t\t1.Addition"); printf("\n\n\t\t\t2.Subraction"); printf("\n\n\t\t\t3.Multiplication "); flushall(); printf("\n\nEnter choice : " ); scanf("%d",&ch); switch(ch) { case 1: printf("Enter the order of the matrices : "); scanf("%d %d",&ma,&na); printf("Enter the input for matrix A : "); input(a,ma,na); printf("Enter the input for matrix B : "); input(b,ma,na); flushall(); add(a,b,ma,na); break; case 2: printf("Enter the order of the matrices : "); scanf("%d %d",&ma,&na); printf("Enter the input for matrix A : "); input(a,ma,na); printf("Enter the input for matrix B : "); input(b,ma,na); flushall(); diff(a,b,ma,na); break; case 3: printf("Enter the order of the Matrix A : "); scanf("%d %d",&ma,&na); printf("Enter the input for matrix A : "); input(a,ma,na); printf("Enter the order of the Matrix B : "); scanf("%d %d",&mb,&nb); printf("Enter the input for matrix B : "); input(b,mb,nb); flushall(); if(na==mb) multi(a,b,ma,na,nb); else printf("This operation cannot be performed on these matirces!!!"); break; case 4: printf("Invalid choice!!!!"); } printf("Do you want to perform another operation (y/n) ? "); scanf("%c", &yn); }while(yn=='y'); getch(); }
void input(int mat[10][10],int m,int n) { int i,j; int x,y; x=wherex(); y=wherey(); flushall(); for(i=0;i { for(j=0;j { gotoxy(x+j*4,y+i); scanf("%d",&mat[i][j]); } } }
void output(int mat[10][10],int m,int n) { int i,j; for(i=0;i { for(j=0;j { printf("%d\t",mat[i][j]); } printf("\n"); } }
void add(int a[10][10],int b[10][10],int m,int n) { int sum[10][10]; int i,j; printf("The sum of the 2 matrice are : \n "); for(i=0;i { for(j=0;j { sum[i][j]=a[i][j]+b[i][j]; } } output(sum,m,n); }
void diff(int a[10][10],int b[10][10],int m,int n) { int d[10][10]={0}; int i,j; flushall(); for(i=0;i { for(j=0;j { d[i][j]=a[i][j]-b[i][j]; } } output(d,m,n); }
void multi(int a[10][10],int b[10][10],int ma,int na,int nb) { int i,j,k; int m[10][10]={0}; flushall(); printf("The product of the 2 matrices are : \n"); for(i=0;i { for(j=0;j { for(k=0;k { m[i][j]+=a[i][k]*b[k][j]; } } } output(m,ma,nb); }
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|