Please help me to write a programme to add two matrices. The matrices should be o 3*4 and must have necessary commend lines so that i can catch it correctly. anyone help me pls?

Recommended Answers

All 8 Replies

Welcome aboard. If you have specific problems when trying to do a program...please post the source code here along with what you think may be wrong. Also post the errors you get, so we can take a look and help you. We are not in the business of doing your home-work for you! You must TRY/show some effort!!

Welcome aboard. If you have specific problems when trying to do a program...please post the source code here along with what you think may be wrong. Also post the errors you get, so we can take a look and help you. We are not in the business of doing your home-work for you! You must TRY/show some effort!!

i have done the programme but yhere are some errors coming in it can you pls find it?
this is the pgm.

#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int i,j,a[3][4],b[3][4],s[3][4];
	//input
	cout<<"input a 3*4 matrix\n";
	for(i=0;i<3;i++)
	{  for(j=0;j<4;j++)
	   cin>>a[i][j];
	}
	cout<<"\input another 3*4 matrix\n";
	for(i=0;i<3;i++)
	{  for(j=0;j<4;j++)
	   cin>>b[i][j];
	}
	//processing
	for(i=0;i<3;i++
	{  for(j=0;j<4;j++)
	   {  s[i][j]=0;
	      s[i][j]=a[i][j]+b[i][j];
	   }
	}
	//output
	clrscr();
	cout<<"first matrix\n";
	for(i=0;i<3;i+)
	{  for(j=0;j<4;j++)
	   cout<<a[i][j]<<'\t';
	   cout<<'\n';
	}
	cout<<"\nsecond matrix\n";
	for(i=0;i<3;i++)
	{  for(j=0;j<4;j++)
	   cout<<b[i][j]<<'\t';
	   cout<<'\n';
	}
	cout<<"\nsum matrix\n";
	for(i=0;i<3;i++)
	{  for(j=0;j<4;j++)
	   cout<<s[i][j]<<'\t';
	   cout<<'\n';
	}
	getch();
}

Can you please list/post/tell what the errors are?

Also: #include<iostream.h> -- old header that shouldn't be used for the past umpteen years #include<conio.h> -- header that should not be used as it's not portable void main() -- main() has NEVER been a void, always an int, see this clrscr(); -- useless function only defined in 1 old compiler, no other compiler has it. getch(); -- another function that should be avoided, only a couple compilers have defined it.

You need a newer book. I hope you aren't learning from an instructor.

WaltP....believe it or not....some professors still stick to the old way of teaching/programing...for example...i lost 10 points once for breaking out of a FOR loop....thats one reason some students are reluctant to really learn c++ and just do it because its a required course or something...and if you something another way and get the same bloody answer...they still take points off!!

I did high school AP computer science in 1999 and a comp sci degree from 2000 to 2005 and was taught #include<iostream.h> all the way through.

Some teachers still use the ancient Turbo C++ because they don't know any better and are just too stupid to upgrade to newer FREE compilers. There is no vaid excuses for any university or college of higher learning in USA and most european nations to do that. Then they have the nerve to charge students $100.00 or so for 20 year old c++ textbooks. Shameful.

WaltP....believe it or not....some professors still stick to the old way of teaching/programing...

Oh, I'm fully aware of that!!!

I agree with Salem: shameful! Would you learn to drive from someone using a Model-T cranker? Would you learn to cook from someone that only uses a toaster oven? Why do they allow instructors to teach programming with equally lacking tools (rhetorical question). Let's all learn to high dive from the guy with the kiddie pool!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.