₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,362 members, 8,421,536 topics. Date: Saturday, 06 June 2026 at 03:41 PM

Toggle theme

C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingC++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? (3503 Views)

1 Reply (Go Down)

C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by 1stdami(op): 6:16pm On Oct 21, 2014
pls i need a c++ code to add, subtract, multiply, and find deteminant of matrix 2x2 or 3x3
Re: C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by LordRahl001: 3:44am On Oct 22, 2014
must it be c++, what about other languageshuh MATLAB could be easier u know!! its just a matter of manipulating 2-3 dimensional arrays!!!!
Re: C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by 1stdami(op): 1:36pm On Oct 22, 2014
LordRahl001:
must it be c++, what about other languageshuh MATLAB could be easier u know!! its just a matter of manipulating 2-3 dimensional arrays!!!!
its some crazy assignment dats why i have no other choice
Re: C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by dgbanj: 2:20pm On Oct 22, 2014
//C++ to Add, Subtract and Multiply
#include<iostream>
using namspace std;
int add(int, int); //function prototypes
int sub(int, int);
int mut(int , int);
int main()
{
int choice,c,d,total;
cout<<"1. Addition\n";
cout<<"2. Subtraction\n";
cout<<"3. Multiplication\n";
cout<<"Enter Your Choice";
cin>>choice;
switch(choice)
{
case 1: cout<<"You Selected Addition\n";
cout<<"Enter Two Numbers:";
cin>>c,d;
total=add(c,d);
cout<<"Result is "<<total;
break;
case 2: cout<<"You Selected Subtraction";
cout<<"Enter Two Numbers:";
cin>>c,d;
total=sub(c,d);
cout<<"Result is "<<total;
break;
case 3: cout<<"You Selected Multiplication";
cout<<"Enter Two Numbers:";
cin>>c,d;
total=mut(c,d);
cout<<"Result is "<<total;
break;
default: cout<<"Unknown Selection";
break;

}
return 0;
}
int add(int a, int b){
return a+b;
}
int sub(int a, int b){
return a-b;
}
int mut(int a, int b){
return a*b;
}
Re: C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by dgbanj: 2:39pm On Oct 22, 2014
//C++ for 2x2 Matrices
#include<iostream>
using namespace std;

int main()
{
int a[][];
int b[][];
int c[][];
int n,i,j;
cout<<"Enter the number of elements\n";
cin>>n;
cout<<"Enter First Array Elements\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
cout<<"\n";
cout<<"Enter Second Array Elements\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>b[i][j];
}
}
cout<<"\n";
cout<<"Result Of Matrices After Multiplication\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]*b[i][j];
cout<<c[i][j]<<"\n";
}
}

return 0;

}


I just wrote this program here didnt compile it, so try and correct minor errors you might encounter. thanks
Re: C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by 1stdami(op): 10:43pm On Oct 22, 2014
the code is nice but 2 many errors need to debug and their are some functions you used i haven't been taught c ++ up to dat smiley.. still a leaner tho
1 Reply

Vb.net Code To Display Image In Picturebox From Sql ServerHelp Me With Code To Disable The Maximize Button On My Jframe (java).Help me convert this Vb6.0 code To Vb.net234

Quadratic Equation Solving App I Developed In PythonCollection Of Nigerian Programming GurusHow To Can I Create Amazon Aws Account Using Nigerian Cards?