Question

5. Write a p rogram that solves the following system of equations using Cramers rule. 5x + 7y =-1 6x+8y = 1 hat reads in three matrices A, B and C and calculates the followi 1 2 -1 0 3 -2 [1-1] 2 3 1 3 1 5 1 a. 2* A+3* B b. C c. C.A

using c++. thanks!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

5. equation solving using cramers rule

//source code //

#include<iostream>

using namespace std;

int main() {
// we solve the linear system ax+by=e cx+dy=f in this form

cout<<"Enter 2 Equation in the format ax+by=e && cx+dy=f"<<endl; // asking user the input Execting a valid input
double a,b,e;
double c,d,f;
cin>>a;
cin>>b;
cin>>e;
cin>>c;
cin>>d;
cin>>f;

double determinant = a*d - b*c; //calculating determinant
if(determinant != 0) { // calculating x,y if determinant is not 0
double x = (e*d - b*f)/determinant;
double y = (a*f - e*c)/determinant;
cout<<"Cramer equations system: result, x = "<<x<<" y = "<<y<<endl;
} else {
cout<<"Cramer equations system: determinant is zero"<<endl;
cout<<"there are either no solutions or many solutions exist"<<endl;
}
getchar();
getchar();
return 0;
}

// sample output for the code

Add a comment
Know the answer?
Add Answer to:
using c++. thanks! 5. Write a p rogram that solves the following system of equations using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT