Question: Write a C Program to solve two simultaneous linear equations with two unknowns. You will receive six single-precision floating-point numbers a, b, c, d, e,
Write a C Program to solve two simultaneous linear equations with two unknowns. You will receive six single-precision floating-point numbers a, b, c, d, e, f each separated by whitespace. You may assume that there will be exactly six of them and that they are indeed floating points.
These numbers are meant to be interpreted as the pair of equations ax+by=c dx+ey=f To solve this, first put the coefficient into a two-by-two matrix: [a b] [de ] And put the constant values into an array: [cf] Then invert the coefficient matrix by finding its determinant: det = ( a*e - b*d ) If the determinant is 0, terminate at this point with the error message "too complicated" The inverse of the coefficient matrix is then [ e/det -b/det ] [ -d/det a/det ] This should be multiplied by the constant array to yield [ (e*c-f*b)/det (a*f-c*d)/det ] You must use two-dimensional arrays in your program. Sample session (bold indicates user input) >./a.out give numbers 123456 x=-1.000000 y=2.000000 >./a.out give numbers 10120120 x=12.000000 y=20.000000 >./a.out give numbers 111111 too complicated >./a.out give numbers 110111 too complicated >./a.out give numbers 1101230100 x=-5.555555 y=5.555555 >./a.out give numbers 112358 x=1.000000 y=1.00000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
