/******************************************************* determinant-3x3.ch Determinant of a 3x3 Matrix Use this program to help students find the determinant of a 3x3 matrix. ************************************************************ Copyright 2014 SoftIntegration Inc. http://www.softintegration.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 *******************************************************/ printf("| a1 b1 c1|\n"); printf("| a2 b2 c2|\n"); printf("| a3 b3 c3|\n"); // initialize variabes used in the program int a1, a2, a3, b1, b2, b3, c1, c2, c3; int first, second, third, det; // reads in values printf("what is a1? "); scanf("%d", &a1); printf("what is b1? "); scanf("%d", &b1); printf("what is c1? "); scanf("%d", &c1); printf("what is a2? "); scanf("%d", &a2); printf("what is b2? "); scanf("%d", &b2); printf("what is c2? "); scanf("%d", &c2); printf("what is a3? "); scanf("%d", &a3); printf("what is b3? "); scanf("%d", &b3); printf("what is c3? "); scanf("%d", &c3); // calculate determinant: a1(b2c3-c2b3) - b1(a2c3-c2a3) + c1(a2b3-b2a3) first = a1*((b2*c3)-(c2*b3)); second = b1*((a2*c3)-(c2*a3)); third = c1*((a2*b3)-(b2*a3)); det = first - second + third; printf("the deteminant of:\n"); printf("| %d %d %d |\n", a1, b1, c1); printf("| %d %d %d |\n", a2, b2, c2); printf("| %d %d %d | is \n", a3, b3, c3); printf("%d\n", det);