First of all i would like to thanks everyone here for providing help, i got so much help from this forum which made me joining it, and i hope to provide any kind of help.
secondly, i'm working on a prject that is supposed to ask the user to enter the dimension of matrices and then add or subtract or multiply or find the transpose of the inverse of the matrix and i have to gove it on monday, i did the program and i knw its nt very good but i did what i can and now its not working properly so if any1 can take a look at it and c if there's anything wrng with it and if u have any suggestions to make it better.
I appreciate any help from you.thanks
The Program:
-----------------
#include<iostream>
using namespace std;
void main()
{
int ia,ja,ib,jb,ma,na,mb,nb,q,s;
float a[10][10], b[10][10],R;
unsigned short int choice; char T,Inv,choice2;
int c[2][2];
float z = a[0][0]*a[1][1] - a[0][1]*a[1][0] ;
float z1 = b[0][0]*b[1][1] - b[0][1]*b[1][0] ;
cout<<"\nEnter dimensions for Matrix A: "; cin>>ma>>na;
cout<<"\nEnter elements for Matrix A:\n";
for(ia=1; ia<=ma; ia++)
{
for(ja=1; ja<=na; ja++)
{
cout <<"( "<< ia << "," << ja<< ") = "; cin >> a[ia][ja];
}
}
cout<<"\nEnter dimensions for Matrix B: "; cin>>mb>>nb;
cout<<"\nEnter elements for Matrix B:\n";
for(ib=1; ib<=mb; ib++)
{
for(jb=1; jb<=nb; jb++)
{
cout <<"( "<< ib << "," << jb<< ") = "; cin >> b[ib][jb];
}
}
again:
cout<<"\nChoose the operation you want (1--->6):\n";
cout<<"\n(1)Addition\n(2)Subtraction\n(3)Multiplication\n(4)Transpose Of A or B\n(5)Find The Inverse Of A or B (only for 2x2 matrix)\n(6)Exit\n";
cin>>choice;
if(choice<1 || choice>6)
{
cout<<"\nInvalid choice.....Please Try again\n\n";
system("pause");
system("cls");
goto again;
}
if(choice==6) goto endprog;
switch(choice)
{
case 1:R=a[ia][ja]+b[ib][jb]; break;
case 2:R=a[ia][ja]-b[ib][jb]; break;
case 3:R=a[ia][ja]*b[ib][jb];
cout<<"\nThe Result = "<<R<<endl;
}
if(choice==4)
{
Transpose:
cout<<"\nEnter The Matrix you want to Transpose: "; cin>>T;
if(T=='A')
{
cout<<"\nThe Transpose of Matrix A is: \n"<<"A"<<a[ja][ia]<<endl;
}
}
else
if(T=='B')
{
cout<<"\nThe Transpose of Matrix B is: \n"<<"B"<<b[jb][ib]<<endl;
}