// DETERMINANTS by a.w.k #include<conio.h> #include<iostream.h> #include<stdlib.h> int main() { int ex,choice,a,b,c,d,e,f,g,h,i,ans; char repeat; clrscr(); do{ cout<<"\n Determinant Solver [with Explaination]"; cout<<"\n Enter your choice..."; cout<<"\n\n Press [1] for 2x2....\n \n Press [2] for 3x3...."; cin>>choice; clrscr(); if(choice==1) { cout<<"\n Enter 4 values of Determinant...."; cin>>a>>b>>c>>d; clrscr(); ans=(a*d-b*c); cout<<"\n Entered determinant is...\n"; cout<<" \n| |"; cout<<" \n| "<<a<<" "<<b<<" | "; cout<<" \n| "<<c<<" "<<d<<" | = "<<ans; cout<<" \n| | "; cout<<"\n Answer is "<<ans; cout<<"\n for Explaination press [1]...."; cin>>ex; if(ex==1) { cout<<"\n\n\n\n ---------------------Explaination----------------------"; cout<<"\n="<<a<<" x "<<d<<" - "<<b<<" x "<<c; cout<<"\n="<<a*d<<" - "<<b*c; cout<<"\n="<<a*d-b*c; cout<<"\n="<<ans; } else { goto again1; } } else if(choice==2) { cout<<"\n Enter 9 values of Determinant...."; cin>>a>>b>>c>>d>>e>>f>>g>>h>>i; clrscr(); cout<<"\n Entered determinant is.....\n"; cout<<"| | "; cout<<" \n| "<<a<<" "<<b<<" "<<c<<" | "; cout<<" \n| "<<d<<" "<<e<<" "<<f<<" | "; cout<<" \n| "<<g<<" "<<h<<" "<<i<<" | "; cout<<" \n| | "; ans=a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-g*e); cout<<"\n Answer is "<<ans; cout<<"\n \nFormula =a (e*i - f*h) - b (d*i - f*g) + c (d*e - g*h)"; cout<<"\n For Explaination press [1]..."; cin>>ex; if(ex==1) { cout<<"\n\n ---------------------Explaination------------------------\n\n"; cout<<"="<<a<<" ("<<e<<" x "<<i<<" - "<<f<<" x "<<h<<") - "<<b<<" ("<<d<<" x "<<i<<" - "<<f<<" x "<<g<<") + "<<c<<" ("<<d<<" x "<<h<<" - "<<g<<" x "<<e<< ") " ; cout<<"\n\n="<<a<<" ("<<e*i<<" - "<<f*h<<") - "<<b<<"("<<d*i<<"-"<<f*g<<") + "<<c<<" ("<<d*h<<"-"<<g*e<< ") "; cout<<"\n\n="<<a<<" ("<<e*i - f*h<<") - "<<b<<"("<<d*i - f*g<<") + "<<c<<" ("<<d*h - g*e<< ") "; cout<<"\n\n="<<a*(e*i-f*h)<<"+"<<-b*(d*i-f*g)<<""<<c*(d*h-g*e); cout<<"\n\n="<<ans; } else { goto again1; } } else cout<<"\n Invalid Choice"; again1: cout<<"\n________________________________"; cout<<"\n\n\n\n [R]epeat or [E]xit...???"; cout<<"\n________________________________"; cin>>repeat; clrscr(); } while(repeat!='e'); clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\tan 'Aditya \a Khare \a Production'"; getch(); }
Good! You have a code. Now What error? Which line? Be descriptive. Usually we don't compile the code as soon as we see it. So say what you want. And people will help.
Captain Jake
Posting Whiz in Training
209 posts since Nov 2011
Reputation Points: 12
Solved Threads: 11