/*    MATRIX ADDITION    */

#include<stdio.h>
#include<conio.h>

#define MAX 100

struct Matrix
{
    int Element[MAX][MAX];
    int No_of_Rows;
    int No_of_Cols;
};

void MatrixAdd(const struct Matrix *,const struct Matrix *,struct Matrix *);
int i,j;
void main()
{
    int p,q;
    struct Matrix Mat1;
    struct Matrix Mat2;
    struct Matrix res;
    clrscr();

    printf("\nEnter size of the Matrix : ");
    scanf("%d%d",&p,&q);

    Mat1.No_of_Rows=Mat2.No_of_Rows=res.No_of_Rows=p;
    Mat1.No_of_Cols=Mat2.No_of_Cols=res.No_of_Cols=q;

    printf("\nEnter Matrix 1\n");

    for(i=0;i<p;i++)
    {
        for(j=0;j<q;j++)
        {
            scanf("%d",&Mat1.Element[i][j]);
            printf("   ");
        }
        printf("\n");
    }

    printf("\nEnter Matrix 2\n");

    for(i=0;i<p;i++)
    {
        for(j=0;j<q;j++)
        {
            scanf("%d",&Mat2.Element[i][j]);
            printf("   ");
        }
        printf("\n");
    }

    MatrixAdd(&Mat1,&Mat2,&res);

    getch();

}

void MatrixAdd( const Matrix *a,const Matrix *b,Matrix *sum )
{

    for(i=0;i<a->No_of_Rows;i++)
    {
        for(j=0;j<a->No_of_Cols;j++)
        {
            sum[i][j] = a->Element[i][j] + b->Element[i][j];

            printf("%d   ",sum[i][j]);
        }
        printf("\n");
    }
}

Use code tags, tell which line is producing that error.

In order to understand the sexual reproduction of snails, you must understand a key word: "hermaphrodite".

Not the answer expected? Well, that's what you get when you don't ask any question. To hone the answer down, you need to be explicit.

Use C language code tags to wrap your source code. Here is a guide.

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.