Hi guys. Need to develop a program is performed using IPC mechanisms one of the following problems: The way - "Channels." Implement the computation of the determinant of a square matrix by expanding it on the determinants of lower order. The "master" process sends the job "driven" processes but the latter perform a calculation of determinants, and then calculates the result of the main process. In other words, need to use the pipe function. I have a working program but without IPC mechanisms. I don't know about pipe function and how it's working. Help please
Code:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int determinant(int n, double mat[n][n])
{
int i,j,i_count,j_count, count=0;
double array[n-1][n-1], det=0;
if(n==1) return mat[0][0];
if(n==2) return (mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0]);
for(count=0; count<n; count++)
{
i_count=0;
for(i=1; i<n; i++)
{
j_count=0;
for(j=0; j<n; j++)
{
if(j == count) continue;
array[i_count][j_count] = mat[i][j];
j_count++;
}
i_count++;
}
det += pow(-1, count) * mat[0][count] * determinant(n-1,array);
}
return det;
}
int main()
{
int i, j, dim;
printf(" Enter n\n");
scanf("%d", &dim);
double matrix[dim][dim];
printf("Enter matrix:\n");
for(i = 0; i < dim; i++)
{
for(j = 0; j < dim; j++)
{
scanf("%lf \n", &matrix[i][j]);
}
}
double x = determinant(dim, matrix);
printf("Determinant = %g\n", x);
return 0;
}