/******************************************************* determinant-2x2.ch Determinant of a 2x2 Matrix Use this program to help students find the determinant of a 2x2 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("| a b |\n"); printf("| c d |\n"); // initialize variabes used in the program int a, b, c, d; int diag1, diag2, det; // reads in values printf("what is a? "); scanf("%d", &a); printf("what is b? "); scanf("%d", &b); printf("what is c? "); scanf("%d", &c); printf("what is d? "); scanf("%d", &d); // calculate the determinant: ad -cb diag1 = a*d; diag2 = c*b; det = diag1 - diag2; printf("the determinant of:\n"); printf("| %d %d |\n", a, b); printf("| %d %d | is ", c, d); printf("%d\n", det);