Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When i compiles this code i get 0 errors and some warnings (31) however it allows me to enter the dimensions of the first matrix prompt user for size of second matrix but closes immediately, can...
void main()
{
int x,y,i,j;
  int cols;
   int rows;
    char ch;
  do
  {




   .....
      cout<<"\n*********************************************************"<<endl;
      cout<<"\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
      cout<<"\n*********************************************************"<<endl;


      cout<<"\nTHIS ASSIGNMENT IS TO COVER THE FOLLOWING: "<<endl;
      cout<<"\n                         > Find and displaying Determinant"<<endl;
      cout<<"\n                         > Find and displaying the Inverse"<<endl;
      cout<<"\n                           matrix"<<endl;
      cout<<"\n                         > Carrying out row transformation"<<endl;
      cout<<"\n                         > Addition & Subtraction"<<endl;
      cout<<"\n                         > Multiplicationn & division"<<endl;
      cout<<"\n"<<endl;
    cout<<"\n1.Add matrices\n2.Subtract matrices\n3.Multiplymatrices\n4.Find determinant\n5.Find INverse"<<endl;
    cout<<"Select any one above , then hit ENTER"<<endl;
    cin>>x;
    if(x==1)
    {cout<<"enter the dimension of matrix A:";
    cin>>rows>>cols;
    Matrix A ;//= Matrix(rows, cols);
    cout<<"enter the elements of matrix A:";
    for (int r = 0; r < rows; r++)
     { for (int c = 0; c < cols; c++)
       {
        cin>>A(r,c);
       }
     }
    cout<<"enter the dimension of matrix B:";
    Matrix B = Matrix(cols, rows);
    cout<<"enter the elements of matrix B:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>B(r,c);
       }
  .............
    }
    else if(x==2)
  {  cout<<"enter the dimension of matrix A:";
    cin>>rows>>cols;
    Matrix A = Matrix(cols, rows);
    cout<<"enter the elements of matrix A:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>A(r,c);
       }
     }


    Matrix B = Matrix(cols, rows);
    cout<<"enter the elements of matrix B:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>B(r,c);
       }
     }
    Matrix C;
     C = A - B;
    printf("A - B = \n");
    C.Print();
    printf("\n");
  }
   else if (x==3)
   {
     cout<<"enter the dimension of matrix A:";
    cin>>rows>>cols;
    Matrix A = Matrix(cols, rows);
    cout<<"enter the elements of matrix A:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>A(r,c);
       }
     }


    Matrix B = Matrix(cols, rows);
    cout<<"enter the elements of matrix B:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>B(r,c);
Posted
Updated 4-Dec-11 16:36pm
v2
Comments
Mohibur Rashid 4-Dec-11 22:37pm    
please try to understand, you must not write your question in the subject

1 solution

Debug your program,

and go through line by line, when it would fail it will prompt an error read the error and figure the error out, Its probably access violation error
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900