can u help me with this plz

R

rami-madini

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

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

and thank u :)
 
I

Ian Collins

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


* 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!
 
R

rami-madini

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

you will get abuse!



im a noob with c++ help me plz

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

void main()
{

float A, B , n;


}
 
R

rami-madini

#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
 
R

rami-madini

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

you will get abuse!



#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?
 
D

David Brown

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

you will get abuse!



#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.
 
O

Osmium

David Brown said:
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!



#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)
 
R

rami-madini

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!
#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
 
T

Thomas Richter

Am 22.05.2014 14:47, schrieb (e-mail address removed):
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.
 
R

rami-madini

Am 22.05.2014 14:47, schrieb




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 :(
 
O

Osmium

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.
 
V

Victor Bazarov

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
 
S

Seungbeom Kim

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.
 
D

David Brown

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.
 
D

David Brown

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.
 
I

Ike Naar

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.
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top