answersLogoWhite

0

#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

16y ago

What else can I help you with?

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);


How do you add fractions in matrices?

The usual rules of addition of fractions apply.


What must be true in order to add matrices?

They must have the same dimensions.


Write a program to add two 3x3 matrices in vb.net?

Here's a simple VB.NET program to add two 3x3 matrices: Module Module1 Sub Main() Dim matrix1(2, 2) As Integer Dim matrix2(2, 2) As Integer Dim result(2, 2) As Integer ' Initialize matrices (example values) For i As Integer = 0 To 2 For j As Integer = 0 To 2 matrix1(i, j) = i + j matrix2(i, j) = (i + j) * 2 result(i, j) = matrix1(i, j) + matrix2(i, j) Next Next ' Display the result For i As Integer = 0 To 2 For j As Integer = 0 To 2 Console.Write(result(i, j) &amp; &quot; &quot;) Next Console.WriteLine() Next End Sub End Module This program initializes two 3x3 matrices, adds them together, and prints the resulting matrix. You can modify the initialization to use specific values as needed.


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)