This is C programming assignment The objective of this homew
This is C programming assignment.
The objective of this homework is to give you practice using make files to compose an executable file from a set of source files and adding additional functions to an existing set of code. This assignment will give you an appreciation for the ease with which well designed software can be extended. For this assignment, you will use both the static and dynamic assignment versions of the matrix software. Using each version, do the following:
1.Develop a module which calculates the transpose of a matrix. Your module should return a matrix with the elements interchanged so that A_out[i][j] = A_in[j][i]. (You should be able to use the same module for both the static and dynamic versions.)
2.Generate a makefile that you can use to compile the set of modules to generate the executable file.
3.Modify the set of software so that the matrix elements are now integers, rather than a double precision float value.
4.Execute your transpose file with both the static and dynamic implementation and the version with integer elements. Copy the outputs to a text file to demonstrate proper execution.
What to submit:
Please submit a copy of the modified source files, makefiles, and a text file(s) that includes execution output that demonstrates proper operation for all cases.
Solution
//1 Module to calculate transpose of a matrix
#include <stdio.h>
#define ROWS 10
#define COLS 10
int main()
{
int A_in[ROWS][COLS], A_out[ROWS][COLS], rows, cols, i, j;
printf(\"Enter rows and columns of matrix: \");
scanf(\"%d %d\", &rows, &cols);
// Storing elements into the matrix
printf(\"\ Enter elements of matrix:\ \");
for(i=0; i<rows; ++i)
for(j=0; j<cols; ++j)
{
printf(\"Enter element matrix%d%d: \",i+1, j+1);
scanf(\"%d\", &A_in[i][j]);
}
// Displaying the matrix A_in[][] */
printf(\"\ Entered Matrix is : \ \");
for(i=0; i<rows; ++i)
for(j=0; j<cols; ++j)
{
printf(\"%d \", A_in[i][j]);
if (j == cols-1)
printf(\"\ \ \");
// Finding the transpose of matrix
for(i=0; i<rows; ++i)
for(j=0; j<cols; ++j)
{
A_out[j][i] = A_in[i][j];
}
// Displaying the transpose of matrix
printf(\"\ Transpose of Matrix:\ \");
for(i=0; i<cols; ++i)
for(j=0; j<rows; ++j)
{
printf(\"%d \",A_out[i][j]);
if(j==rows-1)
printf(\"\ \ \");
}
return 0;
}
}
2.make file helps in compiling the .c program where we declare the compiler details.
# the compiler: gcc for C program, define as g++ for C++
CC = gcc
# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS = -g -Wall

