#include<stdio.h>
void AddMatrix(int[2][3],int[2][3],int[2][3],int,int);


int main()
{


int i,j;
int matrixA[2][3], matrixB[2][3], matrixC[2][3];
printf("This Program is to find the summation of matrixA and matrixB\n\n");


for(i=0;i<=1;i++){
for(j=0;j<=2;j++){
printf("Please enter matrixA[%d][%d]:",i+1,j+1);
scanf("%d", &matrixA[j]);
}
}


printf("\n\n");
for(i=0;i<=1;i++){
for(j=0;j<=2;j++){
printf("Please enter matrixB[%d][%d]:",i+1,j+1);
scanf("%d", &matrixB[j]);
}
}
printf("\n\n");
AddMatirix(matrixA,matrixB,matrixC);
return 0;
}
void AddMatrix(int matrixC[2][3], int matrixA[2][3], int matrixB[2][3], int i, int j)
{


for(i=0;i<=1;i++){
for(j=0;j<=2;j++){


matrixC[2][3] = matrixA[j] + matrixB[j];


}
}



for(i=0;i<=1;i++){
for(j=0;j<=2;j++){
printf("matrixC is the summation of both matrixA and matrixB: %d", matrixC[j]);
}
}
printf("\n\n");
return;
}

please help this out..
I'm confused..

please use code tags...so that your code is more readable...this way more people can help you....

for c++ code, type (code=c++)//your code goes here(/code)

e.g.

#include<stdio.h>
void AddMatrix(int[2][3],int[2][3],int[2][3],int,int);

int main()
{

    int i,j;
    int matrixA[2][3], matrixB[2][3], matrixC[2][3];
    printf("This Program is to find the summation of matrixA and matrixB\n\n");

    for(i=0;i<=1;i++){
        for(j=0;j<=2;j++){
            printf("Please enter matrixA[%d][%d]:",i+1,j+1);
            scanf("%d", &matrixA[i][j]);
        }
    }

    printf("\n\n");
    for(i=0;i<=1;i++){
        for(j=0;j<=2;j++){
            printf("Please enter matrixB[%d][%d]:",i+1,j+1);
            scanf("%d", &matrixB[i][j]);
        }
    }
    printf("\n\n");
    AddMatirix(matrixA,matrixB,matrixC);
    return 0;
}
void AddMatrix(int matrixC[2][3], int matrixA[2][3], int matrixB[2][3], int i, int j)
{

    for(i=0;i<=1;i++){
        for(j=0;j<=2;j++){

            matrixC[2][3] = matrixA[i][j] + matrixB[i][j];

        }
    }


    for(i=0;i<=1;i++){
        for(j=0;j<=2;j++){
            printf("matrixC is the summation of both matrixA and matrixB: %d", matrixC[i][j]);
        }
    }
    printf("\n\n");
    return;
}

First, check your spelling. In line 26, you call function AddMatirix, which of course does not exist.

Your function is written with two int parameters, i and j, which do not convey any information to the function, as written. Why not delete those parameters, declare loop variables in the function.

In line 35, where you store the sum of each pair of elements of the matrix, you are using fixed indexes into matrixC. It should use the loop variables the same as the A and B matrices, as in:

matrixC[i][j] = matrixA[i][j] + matrixB[i][j];

Also, matrixC[2][3] is an element outside the bounds of your matrix. The last legal element is matrixC[1][2]

In the function header, why do you have the matrices out of order.

void AddMatrix(int matrixC[2][3], int matrixA[2][3], int matrixB[2][3], int i, int j)

What you end up doing is storing to the second source matrix the results of adding the first source and the destination, as seen from the main function. Your display of resulting C matrix is in fact showing you the initial content of the B matrix.

#include <stdio.h>

int i;	int j;	int row;	int column;
int sum[10][10];
int sub[10][10];

void dimension(void)
{
	printf("\n\n\tEnter The Dimensions Of The Matrix : ");
	printf("\n\n\t\tROW    :  ");
	scanf("%d", &row);
	printf("\n\n\t\tCOLUMN :  ");
	scanf("%d", &column);
}

void display(int *m[][10],int r,int c)
{
	for(i = 0;i < r;i++)
	{
		printf("\n\n\t");
		for(j = 0;j < c;j++)
		{
			printf("%d\t",(*(*(m + i) + j)));
		}
	}
}

void input(int *m[][10],int r,int c)
{
	printf("\n\n\tEnter The Elements : \n\n");
	for(i = 0;i < r;i++)
	{
		for(j = 0;j < c;j++)
		{
			printf("\t");
			scanf("%d",&(*(*(m + i) + j)));
		}
	}
}

void addition(int m1[][10],int m2[][10],int r ,int c)
{
	for(i = 0;i < r;i++)
	{
		for(j = 0;j < c;j++)
		{
			sum[i][j] = m1[i][j] + m2[i][j];
			printf("[%d][%d]\n",m1[i][j],m2[i][j]);
		}
	}
}

void subtraction(int m1[][10],int m2[][10],int r ,int c)
{
	for(i = 0;i < r;i++)
	{
		for(j = 0;j < c;j++)
		{
			sub[i][j] = m1[i][j] - m2[i][j];
		}
	}
}

int mat1[10][10];
int mat2[10][10];

int main()
{
	dimension();
	input(mat1,row,column);
	input(mat2,row,column);

	printf("\n\n\tMATRIX 1 : ");
	display(mat1,row,column);
	printf("\n\n\tMATRIX 2 : ");
	display(mat2,row,column);


	addition(mat1,mat2,row,column);
	subtraction(mat1,mat2,row,column);

	printf("\n\n\tRESULT OF ADDITION    : ");
	display(sum,row,column);
	printf("\n\n\tRESULT OF SUBTRACTION : ");
	display(sub,row,column);

	return 0;
}

Tell me wats wrong in my code. Urgent!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.