navaneethan

July 19th, 2010, 06:55 AM

#include<stdio.h>

#include<conio.h>

//void MatrixAdd(const Matrix *a, const Matrix *b, Matrix *c);

struct Matrix {

int Element[100][100];

int No_of_Rows;

int No_of_Cols;

};

typedef struct Matrix Matrix;

void main()

{

int i,j;

Matrix a,b,c;

a.No_of_Rows=2;

a.No_of_Cols=2;

b.No_of_Rows=2;

b.No_of_Cols=2;

clrscr();

printf("Enter the Matrix A:");

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

{

for(j=0;j<=a.No_of_Cols;j++)

{

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

}

}

printf("Enter the MAtrix B:");

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

{

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

{

scanf("%d",&b.Element[i][j]);

}

}

MatrixAdd(&a,&b,&c);

getch();

}

void MatrixAdd(const Matrix *a, const Matrix *b, Matrix *c)

{

int i,j;

for(i=0;i<=a->No_of_Rows;i++)

{

for(j=0;j<=a->No_of_Cols;j++)

{

c->Element[i][j]=a->Element[i][j]+b->Element[i][j];

printf("ANS IS\t%d\t",c->Element[i][j]);

}

printf("\n");

}

}

Hi friends,Just in this program i have got input of two matrices a ,b using stricture,and i passed this to a function,i have done conceptually right but still it gets mess to execute May i know the reason behind this? Actually what is the problem?How to resolve?plz explain friends

#include<conio.h>

//void MatrixAdd(const Matrix *a, const Matrix *b, Matrix *c);

struct Matrix {

int Element[100][100];

int No_of_Rows;

int No_of_Cols;

};

typedef struct Matrix Matrix;

void main()

{

int i,j;

Matrix a,b,c;

a.No_of_Rows=2;

a.No_of_Cols=2;

b.No_of_Rows=2;

b.No_of_Cols=2;

clrscr();

printf("Enter the Matrix A:");

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

{

for(j=0;j<=a.No_of_Cols;j++)

{

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

}

}

printf("Enter the MAtrix B:");

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

{

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

{

scanf("%d",&b.Element[i][j]);

}

}

MatrixAdd(&a,&b,&c);

getch();

}

void MatrixAdd(const Matrix *a, const Matrix *b, Matrix *c)

{

int i,j;

for(i=0;i<=a->No_of_Rows;i++)

{

for(j=0;j<=a->No_of_Cols;j++)

{

c->Element[i][j]=a->Element[i][j]+b->Element[i][j];

printf("ANS IS\t%d\t",c->Element[i][j]);

}

printf("\n");

}

}

Hi friends,Just in this program i have got input of two matrices a ,b using stricture,and i passed this to a function,i have done conceptually right but still it gets mess to execute May i know the reason behind this? Actually what is the problem?How to resolve?plz explain friends