the script should be in c programming Create script that will use a Cramer\'s ru
ID: 3833734 • Letter: T
Question
the script should be in c programming
Create script that will use a Cramer's rule to find the solution of At = b. The A a 3 main B a 3a t matrix. (For the of values of entries in matrices. you have to use POINTERS!) Then the value of x,y and z can be [a_1 a_2 a_3 b_1 b_2 b_3 c_1 c_2 c_3] [x V z] = [d_1 d_2 d_3] x = |d_1 d_2 d_3 b_1 b_2 b_3 c_1 c_2 c_3| / |a_1 a_2 a_3 b_1 b_2 b_3 c_1 c_2 c_3| v = |d_1 d_2 d_3 b_1 b_2 b_3 c_1 c_2 c_3| / |a_1 a_2 a_3 b_1 b_2 b_3 c_1 c_2 c_3| and z = |d_1 d_2 d_3 b_1 b_2 b_3 c_1 c_2 c_3| / |a_1 a_2 a_3 b_1 b_2 b_3 c_1 c_2 c_3| http.// wikipedia_org/ /Cramer%27 _rule indicates the determinant Check you result with [3 1 1 -2 1 1 1 2 0] [x y z] = [6 7 5] if you had hard time reading numbers... [3 1 1 -2 1 1 1 2 0] [x y z] = [6 7 5]Explanation / Answer
#include int det3(int a[3][3]); int main(void) { int A[3][3]; int B[3]; printf("This program uses Cramer's Rule to solve a linear system. Enter each of 3 linear equations as four integers separated by space. For example, x - 2y + 3z = 4 should be entered as 1 -2 3 4"); printf(" Enter equation 1: "); scanf("%i %i %i %i", &A[0][0], &A[0][1], &A[0][2], &B[0]); printf("Enter equation 2: "); scanf("%i %i %i %i", &A[1][0], &A[1][1], &A[1][2], &B[1]); printf("Enter equation 3: "); scanf("%i %i %i %i", &A[2][0], &A[2][1], &A[2][2], &B[2]); /*Finding determinants*/ int detx[3][3] = {{B[0],A[0][1],A[0][2]},{B[1],A[1][1],A[1][2]}, {B[2],A[2][1],A[2][2]}}; int dety[3][3] = {{A[0][0],B[0],A[0][2]},{A[1][0],B[1],A[1][2]}, {A[2][0],B[2],A[2][2]}}; int detz[3][3] = {{A[0][0],A[0][1],B[0]},{A[1][0],A[1][1],B[1]} {A[2][0],A[2][1],B[2]}}; /* Code that determines if the system has a unique solution */ if(det3(A)!=0) printf(" System has a unique solution ( %d,%d,%d)", det3(detx)/det3(A),det3(dety)/det3(A),det3(detz)/det3(A)); else printf(" System does not have a unique solution because determinant is 0"); return 0; } int det3(int a[3][3]) { return (a[0][0]*a[1][1]*a[2][2])-(a[0][0]*a[1][2]*a[2][1]), +(a[0][1]*a[1][2]*a[2][0])-(a[0][1]*a[1][0]*a[2][2]), +(a[0][2]*a[1][0]*a[2][1])-(a[0][2]*a[1][1]*a[2][0]); 2 }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.