Logo 
Search:

C Programming Article

Submit Article
Comments on Program to print addition of two matrices using pointers

Program to print addition of two matrices using pointers.


Rahul Gonnade
Rahul Gonnade from IndiaAug 11
why is this not working ?


#include<stdio.h>
#include<conio.h>
int * accept(int *a,int r,int c)
{
int i,j;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
scanf("%d",a[i][j]);
return a;
}

int *add(int *a,int *b,int r,int c)
{
int i,j,*d;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
d[i][j]=a[i][j]+b[i][j];
return d;
}

int main()
{
int *p,*p1,*p3;
p=accept(p,2,2);
p1=accept(p1,2,2);
p3=add(p,p1,2,2);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d ",p3[i][j]);
}
printf("\n");
}
return 0;
}









Please enter your Comment
  • Comment should be atleast 15 Characters.
  • Please put code inside [Code] your code [/Code].