write a program in c language for the multiplication of two
matrices using pointers?
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,i,j,k;
int a[38][38],b[38][38],p[38][38];
printf("\nEnter the number of rows and coloumns ");
scanf("%d %d",&n,&m);
printf("\nEnter the elements of first matrix ");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",(*(a+i)+j));
}
}
printf("\nMatrix is ");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d",*(*(a+i)+j));
printf("\t");
}
}
printf("\nEnter the elements of second matrix ");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",(*(b+i)+j));
}
}
printf("\nMatrix is ");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d",*(*(b+i)+j));
printf("\t");
}
}
printf("\nAfter multiplication ");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
p[i][j]=0;
for(k=0;k<n;k++)
{
p[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d",*(*(p+i)+j));
printf("\t");
}
}
getch();
}
Is This Answer Correct ? | 35 Yes | 14 No |
Post New Answer View All Answers
What are the header files used in c language?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
Write a code of a general series where the next element is the sum of last k terms.
What is meant by inheritance?
What is restrict keyword in c?
How can you be sure that a program follows the ANSI C standard?
how to create duplicate link list using C???
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
Can stdout be forced to print somewhere other than the screen?
Can two or more operators such as and be combined in a single line of program code?
How do you declare a variable that will hold string values?
Place the #include statement must be written in the program?
Define macros.
Write a program to check armstrong number in c?
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....