//************************

//FILE: matrix.cc

//AUTHOR: Written by Daniel Woodson

//INSTRUCTOR: Dr. Pettey

//COURSE: Discrete Structures

//DUE DATE: Feb 19, 2008

//DESCRIPTION: Program takes in matrix size, then matrix elements.

// Program returns inverse matrix

//INPUTS: matrix size, matrix elements

//OUTPUTS: inverse matrix

//************************

#include <string>

#include <iostream>

using namespace std;

int main(){

//function declarations

//variable declarations

int size; //used to hold the size of the square matrix

float inMatrix[10][10]; //used to hold the user inputed matrix

float outMatrix[10][10]; //used to hold the program generated matrix

float idMatrix[10][10]; //used to hold the an identity matrix

int row; //used to hold the current row

int col; //used to hold the current column

//initalize idMatrix

for(row = 0; row < size; row++){

for(col = 0; col < size; col++){

if(row == col){

idMatrix[row][col] = 1;

}//end if

else{

idMatrix[row][col] = 0;

}//end else

}//end for (col)

}//end for (row)

//prompt user for size

cout << "Input the size of the matrix: ";

//read in size

cin >> size;

//prompt the user for the matrix

cout << "Input the " << size << " X " << size << " matrix: " << endl;

//read in matrix

for(row = 0; row < size; row++){

for(col = 0; col < size; col++){

cin >> inMatrix[row][col];

}//end for (col)

}//end for (row)

//perform opperations

for(row = 0; row < size; row++){

for(col = 0; col < size; col++){

//divide all the elements in a row by the element in the rows identity element

inMatrix[row][col] = (inMatrix[row][col])/(inMa

//and divide the same row of the identity matrix by the same denominator

idMatrix[row][col] = (idMatrix[row][col])/(inMa

}//end for (col)

}//end for (row)

//return results

//Display Message

cout << "The inverse matrix is:" << endl;

//display inverse matrix

for(row = 0; row < size; row++){

for(col = 0; col < size; col++){

cout << idMatrix[row][col] << ", ";

}//end for (col)

cout << endl;

}//end for (row)

return 0;

}//end main

```
//***************************Lab 1*************************************
//FILE: matrix.cc
//AUTHOR: Written by Daniel Woodson
//INSTRUCTOR: Dr. Pettey
//COURSE: Discrete Structures
//DUE DATE: Feb 19, 2008
//DESCRIPTION: Program takes in matrix size, then matrix elements.
// Program returns inverse matrix
//INPUTS: matrix size, matrix elements
//OUTPUTS: inverse matrix
//*********************************************************************
#include <string>
#include <iostream>
using namespace std;
int main(){
//function declarations
//variable declarations
int size; //used to hold the size of the square matrix
float inMatrix[10][10]; //used to hold the user inputed matrix
float outMatrix[10][10]; //used to hold the program generated matrix
float idMatrix[10][10]; //used to hold the an identity matrix
int row; //used to hold the current row
int col; //used to hold the current column
//initalize idMatrix
for(row = 0; row < size; row++){
for(col = 0; col < size; col++){
if(row == col){
idMatrix[row][col] = 1;
}//end if
else{
idMatrix[row][col] = 0;
}//end else
}//end for (col)
}//end for (row)
//prompt user for size
cout << "Input the size of the matrix: ";
//read in size
cin >> size;
//prompt the user for the matrix
cout << "Input the " << size << " X " << size << " matrix: " << endl;
//read in matrix
for(row = 0; row < size; row++){
for(col = 0; col < size; col++){
cin >> inMatrix[row][col];
}//end for (col)
}//end for (row)
//perform opperations
for(row = 0; row < size; row++){
for(col = 0; col < size; col++){
//divide all the elements in a row by the element in the rows identity element
inMatrix[row][col] = (inMatrix[row][col])/(inMatrix[row][row]);
//and divide the same row of the identity matrix by the same denominator
idMatrix[row][col] = (idMatrix[row][col])/(inMatrix[row][row]);
}//end for (col)
}//end for (row)
//return results
//Display Message
cout << "The inverse matrix is:" << endl;
//display inverse matrix
for(row = 0; row < size; row++){
for(col = 0; col < size; col++){
cout << idMatrix[row][col] << ", ";
}//end for (col)
cout << endl;
}//end for (row)
return 0;
}//end main
```