can u help me with this plz

Discussion in 'C++' started by rami-madini@hotmail.com, May 22, 2014.

  1. Guest

    given two square matrices A & B of size n. based on user selection,
    preform one of the following operations:

    >> addition, subtraction, or multiplication of A & B.
    >> Transpose of A & B .
    >> Inverse of A or B only when n=2


    * Note A={a b} inverse A^-1= (1/ad-be){d -b}
    {c d} {-c a}

    and thank u :)
     
    , May 22, 2014
    #1
    1. Advertisements

  2. Ian Collins Guest

    wrote:
    >
    > given two square matrices A & B of size n. based on user selection,
    > preform one of the following operations:
    >
    >>> addition, subtraction, or multiplication of A & B.
    >>> Transpose of A & B .
    >>> Inverse of A or B only when n=2

    >
    > * Note A={a b} inverse A^-1= (1/ad-be){d -b}
    > {c d} {-c a}
    >
    > and thank u :)


    Show an attempt and you may get help, ask for homework to be done and
    you will get abuse!

    --
    Ian Collins
     
    Ian Collins, May 22, 2014
    #2
    1. Advertisements

  3. Guest

    On Thursday, May 22, 2014 2:35:00 PM UTC+4, Ian Collins wrote:
    > rami wrote:
    >
    > >

    >
    > > given two square matrices A & B of size n. based on user selection,

    >
    > > preform one of the following operations:

    >
    > >

    >
    > >>> addition, subtraction, or multiplication of A & B.

    >
    > >>> Transpose of A & B .

    >
    > >>> Inverse of A or B only when n=2

    >
    > >

    >
    > > * Note A={a b} inverse A^-1= (1/ad-be){d -b}

    >
    > > {c d} {-c a}

    >
    > >

    >
    > > and thank u :)

    >
    >
    >
    > Show an attempt and you may get help, ask for homework to be done and
    >
    > you will get abuse!
    >
    >
    >
    > --
    >
    > Ian Collins




    im a noob with c++ help me plz

    this is my attempt
    //
    #include<iostream>
    using namespace std;

    void main()
    {

    float A, B , n;


    }
     
    , May 22, 2014
    #3
  4. Guest

    #include<iostream>
    using namespace std;


    void main()
    {
    float A[2][2] , B[2][2] ;

    cout<<"\nEnter matrix A:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)
    cin>>A[j];
    }

    cout<<"\nEnter matrix B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0;j<2;j++)
    cin>>B[j];
    }

    cout<<"\nAddition of matrix A&B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)

    cout<<A[j]+B[j]<<"\t";
    cout<<endl;
    }

    cout<<"\nSubtraction of matrix A&B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)

    cout<<A[j]-B[j]<<"\t";
    cout<<endl;
    }

    cout<<"\nMultiplication of matrix A&B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)

    cout<<A[j]*B[j]<<"\t";
    cout<<endl;
    }


    cout<<endl;
    system("pause");
    }

    is this right answer im i missing some thing?
    help plz
     
    , May 22, 2014
    #4
  5. Guest

    On Thursday, May 22, 2014 2:35:00 PM UTC+4, Ian Collins wrote:
    > rami wrote:
    >
    > >

    >
    > > given two square matrices A & B of size n. based on user selection,

    >
    > > preform one of the following operations:

    >
    > >

    >
    > >>> addition, subtraction, or multiplication of A & B.

    >
    > >>> Transpose of A & B .

    >
    > >>> Inverse of A or B only when n=2

    >
    > >

    >
    > > * Note A={a b} inverse A^-1= (1/ad-be){d -b}

    >
    > > {c d} {-c a}

    >
    > >

    >
    > > and thank u :)

    >
    >
    >
    > Show an attempt and you may get help, ask for homework to be done and
    >
    > you will get abuse!
    >
    >
    >
    > --
    >
    > Ian Collins




    #include<iostream>
    using namespace std;


    void main()
    {
    float A[2][2] , B[2][2] ;

    cout<<"\nEnter matrix A:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)
    cin>>A[j];
    }

    cout<<"\nEnter matrix B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0;j<2;j++)
    cin>>B[j];
    }

    cout<<"\nAddition of matrix A&B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)

    cout<<A[j]+B[j]<<"\t";
    cout<<endl;
    }

    cout<<"\nSubtraction of matrix A&B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)

    cout<<A[j]-B[j]<<"\t";
    cout<<endl;
    }

    cout<<"\nMultiplication of matrix A&B:\n";
    for(int i=0; i<2; i++)
    {
    for(int j=0; j<2; j++)

    cout<<A[j]*B[j]<<"\t";
    cout<<endl;
    }


    cout<<endl;
    system("pause");
    }

    is this the right answer ?
    im i missing some thing?
     
    , May 22, 2014
    #5
  6. David Brown Guest

    On 22/05/14 13:42, wrote:
    > On Thursday, May 22, 2014 2:35:00 PM UTC+4, Ian Collins wrote:
    >> rami wrote:
    >>
    >>>

    >>
    >>> given two square matrices A & B of size n. based on user selection,

    >>
    >>> preform one of the following operations:

    >>
    >>>

    >>
    >>>>> addition, subtraction, or multiplication of A & B.

    >>
    >>>>> Transpose of A & B .

    >>
    >>>>> Inverse of A or B only when n=2

    >>
    >>>

    >>
    >>> * Note A={a b} inverse A^-1= (1/ad-be){d -b}

    >>
    >>> {c d} {-c a}

    >>
    >>>

    >>
    >>> and thank u :)

    >>
    >>
    >>
    >> Show an attempt and you may get help, ask for homework to be done and
    >>
    >> you will get abuse!
    >>
    >>
    >>
    >> --
    >>
    >> Ian Collins

    >
    >
    >
    > #include<iostream>
    > using namespace std;
    >
    >
    > void main()
    > {
    > float A[2][2] , B[2][2] ;
    >
    > cout<<"\nEnter matrix A:\n";
    > for(int i=0; i<2; i++)
    > {
    > for(int j=0; j<2; j++)
    > cin>>A[j];
    > }
    >
    > cout<<"\nEnter matrix B:\n";
    > for(int i=0; i<2; i++)
    > {
    > for(int j=0;j<2;j++)
    > cin>>B[j];
    > }
    >
    > cout<<"\nAddition of matrix A&B:\n";
    > for(int i=0; i<2; i++)
    > {
    > for(int j=0; j<2; j++)
    >
    > cout<<A[j]+B[j]<<"\t";
    > cout<<endl;
    > }
    >
    > cout<<"\nSubtraction of matrix A&B:\n";
    > for(int i=0; i<2; i++)
    > {
    > for(int j=0; j<2; j++)
    >
    > cout<<A[j]-B[j]<<"\t";
    > cout<<endl;
    > }
    >
    > cout<<"\nMultiplication of matrix A&B:\n";
    > for(int i=0; i<2; i++)
    > {
    > for(int j=0; j<2; j++)
    >
    > cout<<A[j]*B[j]<<"\t";
    > cout<<endl;
    > }
    >
    >
    > cout<<endl;
    > system("pause");
    > }
    >
    > is this the right answer ?
    > im i missing some thing?
    >


    Have you tried out your program? Does it work? Does it matter to you
    that you have missed out half the question? Does it matter to you that
    you are printing all the operations, not just the "user selected" one?
    Does it matter to you that you don't know how to do matrix multiplication?

    You also need to learn how to use Usenet (Google Groups mangles posts),
    and how to write in English. It's fine to make a few mistakes with the
    language - but it is /not/ fine to write SMS-speak, or fail to use basic
    capitalisation and punctuation.

    Once you've covered these points, and you again post your best effort at
    solving the problem yourself, you will likely get more help.
     
    David Brown, May 22, 2014
    #6
  7. Osmium Guest

    "David Brown" wrote:

    > On 22/05/14 13:42, wrote:
    >> On Thursday, May 22, 2014 2:35:00 PM UTC+4, Ian Collins wrote:
    >>> rami wrote:
    >>>
    >>>>
    >>>
    >>>> given two square matrices A & B of size n. based on user selection,
    >>>
    >>>> preform one of the following operations:
    >>>
    >>>>
    >>>
    >>>>>> addition, subtraction, or multiplication of A & B.
    >>>
    >>>>>> Transpose of A & B .
    >>>
    >>>>>> Inverse of A or B only when n=2
    >>>
    >>>>
    >>>
    >>>> * Note A={a b} inverse A^-1= (1/ad-be){d -b}
    >>>
    >>>> {c d} {-c a}
    >>>
    >>>>
    >>>
    >>>> and thank u :)
    >>>
    >>>
    >>>
    >>> Show an attempt and you may get help, ask for homework to be done and
    >>>
    >>> you will get abuse!
    >>>
    >>>
    >>>
    >>> --
    >>>
    >>> Ian Collins

    >>
    >>
    >>
    >> #include<iostream>
    >> using namespace std;
    >>
    >>
    >> void main()
    >> {
    >> float A[2][2] , B[2][2] ;
    >>
    >> cout<<"\nEnter matrix A:\n";
    >> for(int i=0; i<2; i++)
    >> {
    >> for(int j=0; j<2; j++)
    >> cin>>A[j];
    >> }
    >>
    >> cout<<"\nEnter matrix B:\n";
    >> for(int i=0; i<2; i++)
    >> {
    >> for(int j=0;j<2;j++)
    >> cin>>B[j];
    >> }
    >>
    >> cout<<"\nAddition of matrix A&B:\n";
    >> for(int i=0; i<2; i++)
    >> {
    >> for(int j=0; j<2; j++)
    >>
    >> cout<<A[j]+B[j]<<"\t";
    >> cout<<endl;
    >> }
    >>
    >> cout<<"\nSubtraction of matrix A&B:\n";
    >> for(int i=0; i<2; i++)
    >> {
    >> for(int j=0; j<2; j++)
    >>
    >> cout<<A[j]-B[j]<<"\t";
    >> cout<<endl;
    >> }
    >>
    >> cout<<"\nMultiplication of matrix A&B:\n";
    >> for(int i=0; i<2; i++)
    >> {
    >> for(int j=0; j<2; j++)
    >>
    >> cout<<A[j]*B[j]<<"\t";
    >> cout<<endl;
    >> }
    >>
    >>
    >> cout<<endl;
    >> system("pause");
    >> }
    >>
    >> is this the right answer ?
    >> im i missing some thing?
    >>

    >
    > Have you tried out your program? Does it work? Does it matter to you
    > that you have missed out half the question? Does it matter to you that
    > you are printing all the operations, not just the "user selected" one?
    > Does it matter to you that you don't know how to do matrix multiplication?
    >
    > You also need to learn how to use Usenet (Google Groups mangles posts),
    > and how to write in English. It's fine to make a few mistakes with the
    > language - but it is /not/ fine to write SMS-speak, or fail to use basic
    > capitalisation and punctuation.
    >
    > Once you've covered these points, and you again post your best effort at
    > solving the problem yourself, you will likely get more help.


    I agree with all of that!

    You have a computer, use it.
    http://en.wikipedia.org/wiki/Matrix_(mathematics)
     
    Osmium, May 22, 2014
    #7
  8. Guest

    On Thursday, May 22, 2014 4:26:32 PM UTC+4, David Brown wrote:
    > On 22/05/14 13:42, rami wrote:
    >
    > > On Thursday, May 22, 2014 2:35:00 PM UTC+4, Ian Collins wrote:

    >
    > >> rami wrote:

    >
    > >>

    >
    > >>>

    >
    > >>

    >
    > >>> given two square matrices A & B of size n. based on user selection,

    >
    > >>

    >
    > >>> preform one of the following operations:

    >
    > >>

    >
    > >>>

    >
    > >>

    >
    > >>>>> addition, subtraction, or multiplication of A & B.

    >
    > >>

    >
    > >>>>> Transpose of A & B .

    >
    > >>

    >
    > >>>>> Inverse of A or B only when n=2

    >
    > >>

    >
    > >>>

    >
    > >>

    >
    > >>> * Note A={a b} inverse A^-1= (1/ad-be){d -b}

    >
    > >>

    >
    > >>> {c d} {-c a}

    >
    > >>

    >
    > >>>

    >
    > >>

    >
    > >>> and thank u :)

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> Show an attempt and you may get help, ask for homework to be done and

    >
    > >>

    >
    > >> you will get abuse!

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> --

    >
    > >>

    >
    > >> Ian Collins

    >
    > >

    >
    > >

    >
    > >

    >
    > > #include<iostream>

    >
    > > using namespace std;

    >
    > >

    >
    > >

    >
    > > void main()

    >
    > > {

    >
    > > float A[2][2] , B[2][2] ;

    >
    > >

    >
    > > cout<<"\nEnter matrix A:\n";

    >
    > > for(int i=0; i<2; i++)

    >
    > > {

    >
    > > for(int j=0; j<2; j++)

    >
    > > cin>>A[j];

    >
    > > }

    >
    > >

    >
    > > cout<<"\nEnter matrix B:\n";

    >
    > > for(int i=0; i<2; i++)

    >
    > > {

    >
    > > for(int j=0;j<2;j++)

    >
    > > cin>>B[j];

    >
    > > }

    >
    > >

    >
    > > cout<<"\nAddition of matrix A&B:\n";

    >
    > > for(int i=0; i<2; i++)

    >
    > > {

    >
    > > for(int j=0; j<2; j++)

    >
    > >

    >
    > > cout<<A[j]+B[j]<<"\t";

    >
    > > cout<<endl;

    >
    > > }

    >
    > >

    >
    > > cout<<"\nSubtraction of matrix A&B:\n";

    >
    > > for(int i=0; i<2; i++)

    >
    > > {

    >
    > > for(int j=0; j<2; j++)

    >
    > >

    >
    > > cout<<A[j]-B[j]<<"\t";

    >
    > > cout<<endl;

    >
    > > }

    >
    > >

    >
    > > cout<<"\nMultiplication of matrix A&B:\n";

    >
    > > for(int i=0; i<2; i++)

    >
    > > {

    >
    > > for(int j=0; j<2; j++)

    >
    > >

    >
    > > cout<<A[j]*B[j]<<"\t";

    >
    > > cout<<endl;

    >
    > > }

    >
    > >

    >
    > >

    >
    > > cout<<endl;

    >
    > > system("pause");

    >
    > > }

    >
    > >

    >
    > > is this the right answer ?

    >
    > > im i missing some thing?

    >
    > >

    >
    >
    >
    > Have you tried out your program? Does it work? Does it matter to you
    >
    > that you have missed out half the question? Does it matter to you that
    >
    > you are printing all the operations, not just the "user selected" one?
    >
    > Does it matter to you that you don't know how to do matrix multiplication?
    >
    >
    >
    > You also need to learn how to use Usenet (Google Groups mangles posts),
    >
    > and how to write in English. It's fine to make a few mistakes with the
    >
    > language - but it is /not/ fine to write SMS-speak, or fail to use basic
    >
    > capitalisation and punctuation.
    >
    >
    >
    > Once you've covered these points, and you again post your best effort at
    >
    > solving the problem yourself, you will likely get more help.



    why are u people so mean:(
    i just asked for help
     
    , May 22, 2014
    #8
  9. Am 22.05.2014 14:47, schrieb :

    >
    > why are u people so mean:(
    > i just asked for help


    People are not mean, people just don't want to make *your* homework. The
    point of homework assignments is to try it yourself. You don't learn
    anything if you just type in the answer from somebody.
     
    Thomas Richter, May 22, 2014
    #9
  10. Guest

    On Thursday, May 22, 2014 6:19:01 PM UTC+4, Thomas Richter wrote:
    > Am 22.05.2014 14:47, schrieb


    >
    >
    >
    > >

    >
    > > why are u people so mean:(

    >
    > > i just asked for help

    >
    >
    >
    > People are not mean, people just don't want to make *your* homework. The
    >
    > point of homework assignments is to try it yourself. You don't learn
    >
    > anything if you just type in the answer from somebody.


    help me to start the code and i will go ahead please :(
     
    , May 22, 2014
    #10
  11. Osmium Guest

    <> wrote:

    > help me to start the code and i will go ahead please :(


    Debugging will be simpler if the matrix contains int, you can change it
    later. I would defer the human interface to the end.

    perhaps something like this.

    #define N 2
    int main()
    {
    int a[N][N] = {3, 4, 5, 6};
    int b[N][N] ={37, 38, 39, 40};
    iint c[N][N];
    .stuff such as:
    add(a, b, c);
    show(c);

    Write a function to display a matrix for debugging purposes (show()). Get it
    working to your satisfaction. Start writing functions for each of the
    required results. Start with add, I think your code was OK. Gradually add
    the harder stuff. Add a bit,
    debug, verify results. . Remember that C++ arrays start with zero. Repeat
    until done. Don't type a bunch of stuff, type as needed for the next few
    minutes of debug. main will be pretty empty, basically the human interface
    and function calls.

    Change N to a variable. Add the human interface. main will be pretty empty,
    basically the human interface and function calls. Done.
     
    Osmium, May 22, 2014
    #11
  12. On 5/22/2014 12:40 PM, Osmium wrote:
    > <> wrote:
    >
    >> help me to start the code and i will go ahead please :(

    >
    > Debugging will be simpler if the matrix contains int, you can change it
    > later. I would defer the human interface to the end.
    >
    > perhaps something like this.
    >
    > #define N 2
    > int main()
    > {
    > int a[N][N] = {3, 4, 5, 6};
    > int b[N][N] ={37, 38, 39, 40};
    > iint c[N][N];
    > .stuff such as:
    > add(a, b, c);
    > show(c);
    > [..]
    >
    > Change N to a variable. [..]


    That's pretty non-trivial, and likely not feasible for an admitted
    newbie. To OP: ignore this recommendation. If you can make it work for
    fixed-size matrices, you'd get a passing grade.

    V
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, May 22, 2014
    #12
  13. On 2014-05-22 05:47, wrote:
    >
    > why are u people so mean:(
    > i just asked for help


    I don't think they are mean, but even if they were, they're
    not obliged in any way to help you, but they are free to choose
    whatever request to help. One of the most fundamental things
    to remember when asking help in Usenet is that this is not
    a customer support for a paid product, but a voluntary,
    collaborative discussion forum. Therefore, you'd be better off
    following the rules and etiquette to elicit help.

    --
    Seungbeom Kim
     
    Seungbeom Kim, May 22, 2014
    #13
  14. David Brown Guest

    On 22/05/14 14:47, wrote:
    > On Thursday, May 22, 2014 4:26:32 PM UTC+4, David Brown wrote:
    >> On 22/05/14 13:42, rami wrote:


    >>
    >>> is this the right answer ?

    >>
    >>> im i missing some thing?

    >>
    >>>

    >>
    >>
    >>
    >> Have you tried out your program? Does it work? Does it matter to you
    >>
    >> that you have missed out half the question? Does it matter to you that
    >>
    >> you are printing all the operations, not just the "user selected" one?
    >>
    >> Does it matter to you that you don't know how to do matrix multiplication?
    >>
    >>
    >>
    >> You also need to learn how to use Usenet (Google Groups mangles posts),
    >>
    >> and how to write in English. It's fine to make a few mistakes with the
    >>
    >> language - but it is /not/ fine to write SMS-speak, or fail to use basic
    >>
    >> capitalisation and punctuation.
    >>
    >>
    >>
    >> Once you've covered these points, and you again post your best effort at
    >>
    >> solving the problem yourself, you will likely get more help.

    >
    >
    > why are u people so mean:(
    > i just asked for help
    >


    Read what I wrote. I am giving you the best help you could hope for.
    Anyone who provides you with code or more hints is doing you a
    disfavour, and in the long run it will be worse for you and worse for
    the rest of the world when yet another incompetent programmer cheats his
    way through his homework and ends up in a job he is unable to do
    properly. Follow my advice, and you stand a chance of /learning/
    something. And when you have something that is a solid attempt, people
    here will try to give tips on how to improve it - but we will not do
    your homework for you.

    And no matter what you end up doing in life - be it a C++ programmer or
    something else - you will do it better if you learn to communicate in a
    proper language. When you write like an adult, people will treat you
    like an adult. When you write like a grumpy teenager, people will treat
    you as one.
     
    David Brown, May 22, 2014
    #14
  15. David Brown Guest

    On 22/05/14 16:48, wrote:
    > On Thursday, May 22, 2014 6:19:01 PM UTC+4, Thomas Richter wrote:
    >> Am 22.05.2014 14:47, schrieb

    >
    >>
    >>
    >>
    >>>

    >>
    >>> why are u people so mean:(

    >>
    >>> i just asked for help

    >>
    >>
    >>
    >> People are not mean, people just don't want to make *your* homework. The
    >>
    >> point of homework assignments is to try it yourself. You don't learn
    >>
    >> anything if you just type in the answer from somebody.

    >
    > help me to start the code and i will go ahead please :(
    >


    You don't need help getting started - your start was fine (for homework
    at this level). If you ask 10 people in this group how they would
    structure the code for this problem, you'd get at least 12 different
    answers. So your code is not a bad beginning for the way /you/ want to
    write it - but you need to do more, such as testing, before anyone else
    can really help you.
     
    David Brown, May 22, 2014
    #15
  16. Ike Naar Guest

    On 2014-05-22, Victor Bazarov <> wrote:
    > On 5/22/2014 12:40 PM, Osmium wrote:
    >> <> wrote:
    >>
    >>> help me to start the code and i will go ahead please :(

    >>
    >> Debugging will be simpler if the matrix contains int, you can change it
    >> later. I would defer the human interface to the end.
    >>
    >> perhaps something like this.
    >>
    >> #define N 2
    >> int main()
    >> {
    >> int a[N][N] = {3, 4, 5, 6};
    >> int b[N][N] ={37, 38, 39, 40};
    >> iint c[N][N];
    >> .stuff such as:
    >> add(a, b, c);
    >> show(c);
    >> [..]
    >>
    >> Change N to a variable. [..]

    >
    > That's pretty non-trivial, and likely not feasible for an admitted
    > newbie. To OP: ignore this recommendation. If you can make it work for
    > fixed-size matrices, you'd get a passing grade.


    If the implementation supports VLAs it's not so difficult.
     
    Ike Naar, May 22, 2014
    #16
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Replies:
    8
    Views:
    1,209
    John C. Bollinger
    Mar 4, 2005
  2. Kulbir
    Replies:
    0
    Views:
    453
    Kulbir
    Jan 17, 2006
  3. Kulbir
    Replies:
    1
    Views:
    830
    IchBin
    Jan 17, 2006
  4. brian

    Size of my Struct? PLZ PLZ reply

    brian, Nov 23, 2004, in forum: C Programming
    Replies:
    7
    Views:
    772
    -berlin.de
    Nov 25, 2004
  5. Replies:
    1
    Views:
    671
  6. Replies:
    2
    Views:
    578
    Nick Keighley
    Nov 24, 2006
  7. Replies:
    1
    Views:
    637
  8. nocturnal
    Replies:
    1
    Views:
    778
    nocturnal
    Jul 10, 2009
Loading...