Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,199,398 members, 7,971,439 topics. Date: Thursday, 10 October 2024 at 10:01 AM |
Nairaland Forum / Science/Technology / Programming / C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? (3431 Views)
Vb.net Code To Display Image In Picturebox From Sql Server / Help Me With Code To Disable The Maximize Button On My Jframe (java). / Help me convert this Vb6.0 code To Vb.net (2) (3) (4)
C++ Code To Add, Subtract, Multiply, And Find Deteminant Of Matrix? by 1stdami(m): 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 languages 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(m): 1:36pm On Oct 22, 2014 |
LordRahl001: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(m): 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 .. still a leaner tho |
(1) (Reply)
Why Do Young Startup Founders Drop Out Of School / Programming: Which Is Most Lucrative? / Sending Sms Using Asp.net (c#) Through Http
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13 |