![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Concept explainers
In this c langauge program, please change the code but same output.
Source Code:
/**
* C program to multiply two matrix using pointers
*/
#include <stdio.h>
#define ROW 100
#define COL 100
/* Function declarations */
void matrixInput(int mat[][COL],int,int);
void matrixPrint(int mat[][COL],int,int);
void matrixMultiply(int mat1[][COL], int mat2[][COL], int res[][COL],int,int);
int main()
{
int mat1[ROW][COL];
int mat2[ROW][COL];
int product[ROW][COL];
int r,c;
printf("Enter rows of the matrices: ");
scanf("%d",&r);
printf("Enter Column of the matrices: ");
scanf("%d",&c);
/*
* Input elements in matrices.
*/
printf("Enter elements in first matrix of size %dx%d\n", r, c);
matrixInput(mat1,r,c);
printf("Enter elements in second matrix of size %dx%d\n", r, c);
matrixInput(mat2,r,c);
// Call function to multiply both matrices
matrixMultiply(mat1, mat2, product,r,c);
// Print first matrix
printf("First Matrix is: \n");
matrixPrint(mat1,r,c);
// Print Second matrix
printf("Second Matrix is: \n");
matrixPrint(mat2,r,c);
// Print product of both matrix
printf("Product of both matrices is : \n");
matrixPrint(product,r,c);
return 0;
}
/**
* Function to input elements in matrix from user.
*/
void matrixInput(int mat[][COL],int row,int col)
{
int i,j;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("Enter element (%d %d): ",i,j);
scanf("%d", (*(mat + i) + j));
}
}
}
/**
* Function to print elements in a two-dimensional array.
*/
void matrixPrint(int mat[][COL],int row,int col)
{
int i,j;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
printf("%d ", *(*(mat + i) + j));
}
printf("\n");
}
}
/**
* Function to multiply two matrices.
*/
void matrixMultiply(int mat1[][COL], int mat2[][COL], int res[][COL],int row,int col)
{
int i,j,k;
int sum;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
sum = 0;
/*
* Find sum of product of each elements of
* rows of first matrix and columns of second
* matrix.
*/
for (k = 0; k < col; k++)
{
sum += (*(*(mat1 + i) + k)) * (*(*(mat2 + k) + j));
}
/*
* Store sum of product of row of first matrix
* and column of second matrix to resultant matrix.
*/
*(*(res + i) + j) = sum;
}
}
}
See the picture below that's the output of this program. Thank you
![Enter rows of the matrices: 2
Enter Column of the matrices: 2
Enter elements in first matrix of size 2x2
Enter element (0 0): 1
Enter element (0 1) : 2
Enter element (1 0): 3
Enter element (1 1): 4
Enter elements in second matrix of size 2x2
Enter element (0 0) : 5
Enter element (0 1): 6
Enter element (1 0): 0
Enter element (1 1): 7
First Matrix is:
1 2
3 4
Second Matrix is:
15 6
0 7
Product of both matrices is :
5 20
15 46](https://content.bartleby.com/qna-images/question/5ad62bda-1333-4080-a074-f40aa36e56fd/a5f0e0f9-85d6-4989-9334-fc254048372d/a3zs9to_thumbnail.jpeg)
![Check Mark](/static/check-mark.png)
Step by stepSolved in 2 steps with 1 images
![Blurred answer](/static/blurred-answer.jpg)
- I need help making this C program which uses pointers. #include<stdio.h> //for printf and scanf #include<ctype.h> //for tolower function //function prototypes void Greeting(); //welcome the user to the gas station app void ViewAndGetSelection(char* selectionPtr); //input: the user's selection (input/output parameter) //display the program options and get the users selection //use an input/output parameter for the selection void ProcessSelection(char selection, double* balancePtr); //input: the user's selection by copy (input parameter) //input: the account balance (input/output parameter) //display a message that the selection has been entered //display the balance when the user enters 'b' //allow the user to add money to the account when the user enters 'u' int main() { char choiceInMain; double balanceInMain = 0.00; //call the greeting function //view and get the selection - function call //change the selection to lower or upper case //make sure the user did not enter q…arrow_forwardLab 09 Understanding C++ pointers Assume p1, p2, and p3 are pointers to integer numbers. As an example, consider int n1 = 33; int n2 = 11; int n3 = 22; You are asked to implement the function void arrangelnOrder(int* p1, int* p2, int* p3) The function's goal is to order the data referenced by the pointers in such a way that after the function is called, p1 points to the smallest and p3 points to the largest of the three values. Test your function using the following main() method. Make sure your app works for all possible combinations of integer values referenced by the pointers. int main() { int n1 = 33; int n2 = 11; int n3 = 22; cout << "Before the call. n1=" << n1<< ", n2="<< n2 << ", n3=" << n3 << endl; arrangelnOrder(&n1, &n2, &n3); cout << "After the call. n1=" << n1 << ", n2=" << n2 << ", n3=" << n3 << endl; } It should produce the following output. Before the call. n1=33, n2=11, n3=22 After the call. n1=11, n2=22, n3=33 NOTE. Do not copy the data value into an array/vector and…arrow_forwardIN C PROGRAMMING LANGUAGE: Please write a pointer version of squeeze() named psqueeze(char *s, char c) which removes c from the string s.arrow_forward
- C++ Dynamic Array Project Part 2arrow_forwardComplete the C++ code below#include "std_lib_facilities.h"/*1. Define a function which calculates the outer product of two vectors. The function return is a matrix. */vector<vector<int>> outerProduct(vector<int>& A, vector<int>& B){//implement here}/*2. Define a function which transposes a matrix. */vector<vector<int>> transpose(vector<vector<int>>& A){//implementation}/*3. Define a function which calculates the multiplication of a matrix and it's transpose. */vector<vector<int>> product(vector<vector<int>>& A){// implementation}/*4. Define a print out function that will print out a matrix in the following format:Example: a 3 by 4 matrix should have the print out:1 2 3 42 3 4 53 4 5 6*/void printMatrix(vector<vector<int>>& A){// implementation}int main(){// Define both vector A and vector Bvector<int> A = {1 ,2, 3, 4, 5};vector<int> B = {1, 2, 3};/*Test outerProduct…arrow_forwardPlease complete the following guidelines and hints. Using C language. Please use this template: #include <stdio.h>#define MAX 100struct cg { // structure to hold x and y coordinates and massfloat x, y, mass;}masses[MAX];int readin(void){/* Write this function to read in the datainto the array massesnote that this function should return the number ofmasses read in from the file */}void computecg(int n_masses){/* Write this function to compute the C of Gand print the result */}int main(void){int number;if((number = readin()) > 0)computecg(number);return 0;}Testing your workTypical Input from keyboard:40 0 10 1 11 0 11 1 1Typical Output to screen:CoG coordinates are: x = 0.50 y = 0.50arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)