Add to Favorites    Make Home Page 21884 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » MATRIX ADDITION AND MULTIPLICATION

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title MATRIX ADDITION AND MULTIPLICATION
Author Raji
Author Email rajesh_ [at] myself.com
Description This program will add or multiply two matrix on the basis of given choice. It was the first question of my assingment in my 3rd sem.
Am a student of m.p.christian college of engg. and technology, bhilai.

Category C » Beginners / Lab Assignments
Hits 388178
Code Select and Copy the Code
Code : #include<iostream.h> #include<conio.h> #include<process.h> int a[10][10],b[10][10],x[10][10]; void add() { int r,c,i,j,n; cout<<"ENTER THE ORDER OF MATRIX : "; cin>>n; r=n; c=n; cout<<"ENTER THE ELEMENTS FOR MATRIX 'A' :"<<endl; for(i=0;i<r;i++) { for(j=0;j<c;j++) { cin>>a[i][j]; } } cout<<"ENTER THE ELEMENTS FOR MATRIX 'B' : "<<endl; for(i=0;i<r;i++) { for(j=0;j<c;j++) { cin>>b[i][j]; } } clrscr(); cout<<"MATRIX 'A' IS "<<endl; for(i=0;i<r;i++) { for(j=0;j<c;j++) { cout<<a[i][j]<<" "; } cout<<endl; } cout<<"MATRIX 'B' IS "<<endl; for(i=0;i<r;i++) { for(j=0;j<c;j++) { cout<<b[i][j]<<" "; } cout<<endl; } //.....................ADDITION OF MATRIX........................ for(i=0;i<r;i++) { for(j=0;j<c;j++) { x[i][j]=a[i][j]+b[i][j]; } } cout<<"THE SUM OF TWO ENTERED MATRIX IS "<<endl; for(i=0;i<r;i++) { for(j=0;j<c;j++) { cout<<x[i][j]<<" "; } cout<<endl; } } void multiply() { int r1,c1,r2,c2,i,j,k; clrscr(); cout<<"ENTER THE NO.OF ROWS OF MATRIX (A) : "; cin>>r1; cout<<"ENTER THE NO.OF COLOUMS OF MATRIX (A) :"; cin>>c1; cout<<"ENTER THE ELEMENTS FOR MATRIX (A) :"<<endl; for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { cin>>a[i][j]; } } cout<<"ENTER THE NO.OF ROWS OF MATRIX (B) : "; cin>>r2; cout<<"ENTER THE NO.OF COLOUMS OF MATRIX (B) : "; cin>>c2; cout<<"ENTER THE ELEMENTS FOR MATRIX (B) :"<<endl; for(i=0;i<r2;i++) { for(j=0;j<c2;j++) { cin>>b[i][j]; } } clrscr(); cout<<"MATRIX 'A' IS "<<endl; for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { cout<<a[i][j]<<" "; } cout<<endl; } cout<<"MATRIX 'B' IS "<<endl; for(i=0;i<r2;i++) { for(j=0;j<c2;j++) { cout<<b[i][j]<<" "; } cout<<endl; } if(c1!=r2) { cout<<"MULTIPLICATION IS NOT POSSIBLE "; } else { for(i=0;i<r1;i++) { for(j=0;j<c2;j++) { x[i][j]=0; for(k=0;k<c1;k++) { x[i][j]=x[i][j]+(a[i][k]*b[k][j]); } } } } cout<<"MULTIPLICATION OF TWO MATRIX IS "<<endl; for(i=0;i<r1;i++) { for(j=0;j<c2;j++) { cout<<x[i][j]<<" "; } cout<<endl; } } void main() { clrscr(); while(1) { int ch; cout<<" "; cout<<"...ENTER YOUR CHOICE........"<<endl; cout<<"1. ADDITION OF TWO MATRIX "<<endl; cout<<"2. MULTIPLICATION OF TWO MATRIX "<<endl; cout<<"3. EXIT "<<endl; cin>>ch; switch(ch) { case 1: add(); break; case 2: multiply(); break; case 3: exit(0); default : cout<<"INVALID CHOICE !! ENTER CORRECT CHOICE"; } //getch(); } }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=918


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review