Hi everyone
I am new to this site and also new to programming world
can anybody help me writing C code for matrix multiplication (without using pointers)
Amit
6 61928
Hi everyone
I am new to this site and also new to programming world
can anybody help me writing C code for matrix multiplication (without using pointers)
Amit
You'd have to try writting something first. It is eaier to help when you've shown some of your ideas first.
Hi everyone
I am new to this site and also new to programming world
can anybody help me writing C code for matrix multiplication (without using pointers)
Amit
Hi amrit...Iam writing the simple matrix multiplication code for you without using pointers... 
/* Description:To multiply given to matrix using arrays*/

#include<stdio.h>

#include<math.h>

main()

{

int i,j,k;

int a,b,c;/*three variables to get the row and colum of the two matrix*/

int sum;

int m[10][10],n[10][10],l[10][10];

printf("The first matrix:\n");

printf("Enter the number of rows and columns for the first matrix:\t") ;

scanf("%d%d",&a,&b);

printf("The Second matrix:\n");

printf(Enter the rows and columns of the second matrix:\t:);

scanf("%d%d",&b,&c);


/* Note: For matrix multiplication the number of columns in the first matrix should be equal to the number of rows in the second message*/


printf(":Enter the values of the first matrix:\n");

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

{

for(j=0;j<b;j++)

{

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

}

}

printf("Enter the values of the second matrix:\n");

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

{

for(j=0;j<c;j++)

{

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

}

}

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

{

for(j=0;j<c;j++)

{

sum=0;

for(k=0;k<b;k++)

{

sum=sum+(m[i][k]*n[k][j]);

l[i][j]=sum;

}

}

}

printf("The multiplied matrix is:\n);

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

{

for(j=0;j<c;j++)

{

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

printf("\t");

}

printf("\n");

}

/*This the simple way to do matrix multiplication....You can also modify the program to your own choice...*/
Hi everyone
I am new to this site and also new to programming world
can anybody help me writing C code for matrix multiplication (without using pointers)
Amit
Amit I have told you the program.just work on th logic Behind it and try to modify the program...
Hey! Can you post the code in C++ also, I really needs this code for my homework, but you have it in C.
here is the code for c++=====>
# include <iostream.h>
# include <conio.h>
void main ()
{
clrscr();
int i,j,k,sum,a,b,c;
int m[10][10];
int n[10][10];
int l[10][10];
cout<<"ENTER THE NO. OF ROWS AND COLUMN OF FIRST MATRIX";
cin>>a>>b;
cout<<"ENTER THE VALUES OF FIRST MATRIX";
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
cin>>m[i][j];
}
}
cout<<"ENTER THE NO. OF ROWS AND COLUMN OF SECOND MATRIX";
cin>>b>>c;
cout<<"ENTER THE VALUES OF SECOND MATRIX";
for(i=0;i<b;i++)
{
for(j=0;j<c;j++)
{
cin>>n[i][j];
}
}
for(i=0;i<a;i++)
{
for(j=0;j<c;j++)
{
sum=0;
for(k=0;k<b;k++)
{
sum=sum+m[i][k]*n[k][j];
l[i][j]=sum;
}
}
}
cout<<"THE RESULTANT MATRIX IS"<<endl;
for(i=0;i<a;i++)
{
for(j=0;j<c;j++)
{
cout<<l[i][j]<<" ";
}
cout<<endl;
}
getch();
}
======> HERE IS FOR JAVA MATRIX MULTIPLICATION
int A[][]=new int[3][3];
int B[][]=new int[3][3];
int C[][]=new int[3][3];
Scanner srh=new Scanner(System.in);
Random rnd=new Random();
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.println("Enter A: ");
A[i][j]=srh.nextInt();
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.println("Enter B: ");
B[i][j]=srh.nextInt();
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
C[i][j]=0;
for(int k=0;k<3;k++){
C[i][j]+=A[i][k]*B[k][j];
}
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.println("Value of C: "+C[i][j]);
}
}
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael Bader 
last post by:
Hi,
I'm currently working on a matrix multiplication code (matrix times
matrix), and have come along some interesting/confusing results
concerning the running time of the (apparently) same...

by: christopher diggins 
last post by:
Here is some code I wrote for Matrix multiplication for arbitrary
dimensionality known at compiletime. I am curious how practical it is. For
instance, is it common to know the dimensionality of...

by: lituncse 
last post by:
dear friends,
i have come across a problem which is difficult to solve for me.it's about starssen's matrix multiplication.in general matrix multiplication we need 8 multiplications and 4 additions...

by: VijaKhara 
last post by:
Hi all,
Is there any method which can implememt the matrix multiplication
faster than using the formula as we often do by hand?
I am writing the following code and my matrice: one is 3x40000 and...

by: amitsoni.1984 
last post by:
Hi,
Is there any direct function for matrix multiplication in Python or
any of its packages? or do we have to multiply element by element?
Thank you,
Amit

by: Sozos 
last post by:
Hi guys. I have a problem with writing the base case for the following matrix multiplication function I have implemented. Please help.
#define index(i,j,power) (((i)<<(power))+(j))
void...

by: joegao1 
last post by:
can some one give me a hint?
I want to program the code for matrix multiplication with as less arithmetical / multiplication operations as possible.
my task is to calculate the matrix...

by: isladogs 
last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
For other local times, please check World Time Buddy
In...

by: jianzs 
last post by:
Introduction
Cloudnative applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...

by: abbasky 
last post by:
### Vandf component communication method one: data sharing
Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...

by: fareedcanada 
last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...

by: davi5007 
last post by:
Hi,
Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

by: MeoLessi9 
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

by: DolphinDB 
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...

by: DolphinDB 
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion highfrequency records to 61 million...

by: isladogs 
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
 