answersLogoWhite

0


Best Answer

#include
#include

// Note: The code is not very good !!!! But, OK for understanding the concept
// of matrix addition using pointers !!!!!
void main ()
{
int data[2][2], data1[2][2];
int *p1,*p2,i,j;
clrscr();

for (i = 0; i <2;i++)
{
for(j=0;j<2;j++)
{
data[i][j] = i+j;
data1[i][j]= i+ 2*j;
}
}

p1 = data[0];
p2 = data1[0];

for (i = 0; i<2;i++)
{
for(j=0;j<2;j++)
{
printf ("data -- %d\t",p1[i]);
}
printf("\n");
}
for (i = 0; i<2;i++)
{
for(j=0;j<2;j++)
{
printf ("data1 -- %d\t",p2[i]);
}
printf("\n");
}
for (i = 0; i <2;i++)
{
for(j=0;j<2;j++)
{
printf ("Sum %d\t",p1[i]+p2[i]);
}
printf("\n");
}
getch();
}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#include<stdio.h>

#include<stdlib.h>

int** addMatrices(int**,int**,int,int);

int main()

{

int **a;int **a1;int **a2;

int i,j,m,n;

printf("Enter the number of rows and columns\n");

scanf("%d",&m);

scanf("%d",&n);

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

{

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

{

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

}

}

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

{

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

{

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

}

}

a2=addMatrices(**a,**a1,m,n);

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

{

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

{

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

}

printf("\n");

}

return 0;

}

int** addMatrices(int** a,int** a1,int m,int n)

{

int **l;int **k;int **q;

int r,s,i,j;

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

{

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

{

q[i][j]=l[i][j]+k[i][j];

}

}

return q;

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

this is immpossible

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to add 2 matrices using pointers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is there any benefit in a C plus plus program to add two matrices?

No.


How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


Write a c program to add 2 no without using plus operator?

You can make use of pointers to achieve this.void add( int *a, int *b){(*a) += (*b);}Now if two numbers a and b are given and you need to store the value in variable c, then you would perform:c = a;add(&c,&b);


What must be true in order to add matrices?

They must have the same dimensions.


How do you add fractions in matrices?

The usual rules of addition of fractions apply.


A graphic artist thinks he can add the matrices below using mental math. Which statement explains why he could be correct?

adding the additive identity matrix does not change the original matrix


How do you add matrices?

You add matrices by adding their respective terms - e.g. the element in the first row and sixth column of the sum is the sum of the elements in the addends' first rows and sixth columns. Wikipedia has a nice example of matrix addition that I linked below.


How do you add the word 'PROOF' on your photograph?

Using a photo editing program such as photo shop, you add something called a "watermark"


Write a c program add two polynomial using link list?

GOUDHMARINI


Can a matrix of 4x5 be added with a matrix with dimensions of 5x3?

No. You can only add matrices of the same size.


Can you add two matrices with different dimensions?

No, you cannot add matricies of different dimention/order (i.e. different number of rows or columns)


How can you add something in the middle of a video?

It depends on what program you are using. Usually there is a File &gt; Import option at the top left of the screen. Try using the program's Help Center option if this does not work.