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

Home » C++ Home » Mathematics Home » To Calculate Determinant of a Matrix Using Recursion

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

Search Projects & Source Codes:

Title To Calculate Determinant of a Matrix Using Recursion
Author Ankit Chaudhary
Author Email ankitchaudhary1985 [at] yahoo.co.in
Description This is a simple program implementing the concept of recursion to calculate the determinant of a matrix of any order.
Category C++ » Mathematics
Hits 437568
Code Select and Copy the Code
Code: //TO CALCULATE THE DETERMINANT OF MATRIX OF ANY ORDER USING RECURSION #include<iostream.h> #include<conio.h> #include<math.h> #include<process.h> void main() { int determinant(int[5][5],int);// FUNCTIONS void read(int[5][5],int); void print(int[5][5],int); // PROTOYPES int a[5][5],l,n; int result; l1:clrscr(); cout<<" ENTER ORDER OF MATRIX(MAX. OF 4X4):"; cin>>l>>n; if(l!=n) { //TESTING CONDITION cout<<" SORRY!!!!!\n ONLY SQUARE MATRIX"; goto l1; } read(a,n); result = determinant(a,n); print(a,n); cout<<" THE DETERMINANT OF THE ABOVE MATRIX IS:"<<result; getch(); } void read(int b[5][5],int m) //FUNCTION FOR READING MATRIX { cout<<" ENTER "<<m*m<<" ELEMENTS OF MATRIX(ROW-WISE):"; for(int i=0;i<m;i++) for(int j=0;j<m;j++) cin>>b[i][j]; } void print(int b[5][5],int m) { clrscr(); //FUNCTION FOR PRINTING MATRIX cout<<" MATRIX IS :- "; for(int i=0;i<m;i++) { cout<<" "; for(int j=0;j<m;j++) cout<<" "<<b[i][j]; } } int determinant(int b[5][5],int m) //FUNCTION TO CALCULATE DETERMINANT { int i,j,sum = 0,c[5][5]; if(m==2) { //BASE CONDITION sum = b[0][0]*b[1][1] - b[0][1]*b[1][0]; return sum; } for(int p=0;p<m;p++) { int h = 0,k = 0; for(i=1;i<m;i++) { for( j=0;j<m;j++) { if(j==p) continue; c[h][k] = b[i][j]; k++; if(k == m-1) { h++; k = 0; } } } sum = sum + b[0][p]*pow(-1,p)*determinant(c,m-1); } return sum; }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

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=1054


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