Turn this C Program into DATA ABSTRACTION: Files: main.c, matrix.h, matrix.c Code:   #include #define ROW 6 #define COL 6   //function prototypes void add(int matrixResult[][COL],int matrixA[] [COL],int matrixB[][COL],int row,int col); void subtract(int matrixResult[][COL],int matrixA[] [COL],int matrixB[][COL],int row,int col); void multiply(int matrixResult[][COL],int matrixA[] [COL],int matrixB[][COL],int row,int col); void display(int matrix[][COL]);   //main function int main() {     //declare and initialize 6*6 matrix     int matrixA[][COL] = {{10,20,30,40,50,60},{7,8,9,10,11,12},                                          {13,14,15,16,17,18},{19,20,21,22,23,24},                                          {25,26,27,28,29,30},{31,32,33,34,35,36}};    //declare and initialize 6*6 matrix    intmatrixB[][COL] = {{1,2,3,4,5,6},{17,28,19,78,34,12},                                        {33,14,25,16,17,18},{19,22,21,22,23,24},                                        {19,26,11,28,29,30},{30,32,23,34,15,16}};      int matrixResult[ROW][COL];    printf("Addition of two matrices:\n");    add(matrixResult,matrixA,matrixB,ROW,COL);    printf("\n\nDifference of two matrices:\n");    subtract(matrixResult,matrixA,matrixB,ROW,COL);    printf("\n\nProduct of two matrices:\n");    multiply(matrixResult,matrixA,matrixB,ROW,COL);    return 0; } //function to add two 6*6 matrix void add(int matrixResult[][COL],int matrixA[][COL], int matrixB[][COL],int row,int col) {    for(int i=0;i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Turn this C Program into DATA ABSTRACTION:

Files: main.c, matrix.h, matrix.c

Code:

 

#include <stdio.h>

#define ROW 6

#define COL 6

 

//function prototypes

void add(int matrixResult[][COL],int matrixA[]

[COL],int matrixB[][COL],int row,int col);

void subtract(int matrixResult[][COL],int matrixA[]

[COL],int matrixB[][COL],int row,int col);

void multiply(int matrixResult[][COL],int matrixA[]

[COL],int matrixB[][COL],int row,int col);

void display(int matrix[][COL]);

 

//main function

int main()

{

    //declare and initialize 6*6 matrix

    int matrixA[][COL] = {{10,20,30,40,50,60},{7,8,9,10,11,12},

                                         {13,14,15,16,17,18},{19,20,21,22,23,24},

                                         {25,26,27,28,29,30},{31,32,33,34,35,36}};

   //declare and initialize 6*6 matrix

   intmatrixB[][COL] = {{1,2,3,4,5,6},{17,28,19,78,34,12},

                                       {33,14,25,16,17,18},{19,22,21,22,23,24},

                                       {19,26,11,28,29,30},{30,32,23,34,15,16}};

 

   int matrixResult[ROW][COL];

   printf("Addition of two matrices:\n");

   add(matrixResult,matrixA,matrixB,ROW,COL);

   printf("\n\nDifference of two matrices:\n");

   subtract(matrixResult,matrixA,matrixB,ROW,COL);

   printf("\n\nProduct of two matrices:\n");

   multiply(matrixResult,matrixA,matrixB,ROW,COL);

   return 0;

}

//function to add two 6*6 matrix

void add(int matrixResult[][COL],int matrixA[][COL],

int matrixB[][COL],int row,int col)

{

   for(int i=0;i<row;i++)

     for(int j=0;j<col;j++)

        matrixResult[i][j] = matrixA[i][j] + matrixB[i][j];

 

   display(matrixResult);

}

//function to subtract two 6*6 matrix

void subtract(int matrixResult[][COL],int matrixA[][COL],

int matrixB[][COL],int row,int col)

{

   for(int i=0;i<row;i++)

     for(int j=0;j<col;j++)

        matrixResult[i][j] = matrixA[i][j] - matrixB[i][j];

 

   display(matrixResult);

}

//function to multiply two 6*6 matrix

void multiply(int matrixResult[][COL],int matrixA[][COL],

int matrixB[][COL],int row,int col)

{

   for(int i=0;i<row;i++)

    {

     for(int j=0;j<col;j++)

      {

         matrixResult[i][j] = 0; //assigning 0

         //find product

        for(int k=0;k<row;k++)

        matrixResult[i][j]+ = matrixA[i][k] * matrixB[k][j];

      }

   }

 display(matrixResult);

}

//function to display 6*6 matrix

void display(int matrix[][COL],

{

   for(int i=0;i<ROW;i++)

    {

     for(int j=0;j<COL;j++)

       printf("%d\t",matrix[i][j]);

     printf("\n"); //new line

    }

}

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Randomized Select Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education