answersLogoWhite

0

# include <stdio.h>

# include <conio.h>

# include <stdlib.h>

# define sz 20

# define INF 200000

void print(unsigned long s[][sz], int i, int j)

{

if (i == j)

printf(" A%d ",i);

else

{

printf(" ( ");

print(s, i, s[i][j]);

print(s, s[i][j] + 1, j);

printf(" ) ");

}

}

void printm(unsigned long m[][sz], int n)

{

int i,j;

for(i=1;i<=n;i++)

{

for(j=1;j<=n;j++)

{

printf("%5d",m[i][j]);

}

printf("\n\n");

}

printf("\nThe No. of multiplication required is : %d",m[1][n]);

}

void Matrix_Chain_Order(int p[],int num)

{

unsigned long m[sz][sz] = {0};

unsigned long s[sz][sz] = {0};

unsigned int q = 0;

int i, j, k, l;

int n = num;

for(i = 1; i <= n; i++)

m[i][i] = 0;

for(l = 2; l <= n; l++)

for(i = 1; i <= (n - l + 1); i++)

{

j = i + l - 1;

m[i][j] = INF;

for(k = i; k <= j - 1; k++)

{

q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];

if(q < m[i][j])

{

m[i][j] = q;

s[i][j] = k;

}

}

}

print(s, i-1, j);

printf("\n\n");

printf("The Minimum No. of Multiplication Required is:\n\n");

printm(m,n);

}

void main()

{

int i,num=0,p[sz]={0};

clrscr();

printf("Enter the number of matrix : ");

scanf("%d",&num);

printf("Enter %d no. of order sequence for %d matrix :\n",num+1,num);

for(i=0;i<=num;i++)

scanf("%d",&p[i]);

printf("\n\n");

printf("MULTIPLICATION SEQUENCE IS : ");

printf("\n\n\t");

Matrix_Chain_Order(p,num);

getch();

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Math & Arithmetic
Related Questions

C program for matrix multiplication using dynamic memory alllocation?

Poor boy


What is matrix programming in C programming?

C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion


Matrix multiplication using mpi?

Check related links


Implementation of a ring of processes using pipes to optimize matrix multiplication?

==Maybe==


Write a c program for matrix addition using function?

#include&lt;


C plus plus program -matrix multiplication using class?

for(int i=0;i


Write a C program using dynamic memory allocation to find the sum of elements of a matrix?

Did you know that memory allocation is not needed to display the matrix? However, the C program is to find the sum of all the elements.


How do you write a C program to find the adjoint of a matrix?

To write a C program to find the adjoint of a matrix, first, you need to create a function to calculate the cofactor of each element in the matrix. Then, construct the adjoint by transposing the cofactor matrix. The program should read the matrix size and elements from user input, compute the cofactors using nested loops, and finally display the adjoint matrix by transposing the cofactor matrix. Make sure to handle memory allocation for dynamic matrices if needed.


What is a matrix calculator used for?

Probably the main reason for using a matrix calculator would be if you are working in algebra. There are other reasons to use the matrix calculator and that would be no different than using a regular calculator; adding, subtracting, multiplication, and division problems. These calculators can be purchased several places, department stores or electronic stores.


How do you write c program to perform sum of elements of matrix using pointers with functions?

i cant write


Write a program using iostreams to take as input two multi-dimensional arrays and print their sum as output Matrix Addition in Matrix format?

http://www.assignmentsclub.com/


How do you do a matrix calculation in casio fx 991 MS?

To perform matrix calculations on a Casio fx-991MS calculator, you first need to enter the matrix into the calculator using the matrix mode. Press the &quot;Mode&quot; button, then select &quot;Matrix&quot; mode by pressing the corresponding number key. Next, input the dimensions of the matrix (rows and columns) and enter the values of the matrix. Once the matrix is entered, you can perform operations such as addition, subtraction, multiplication, and finding the determinant or inverse using the matrix menu options.