Sunday, February 1, 2015
Matrix addition function with keyboard entry in C
#include<stdio.h>
void read(int A[10][10])
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
printf("Enter Element %d %d : ",i,j);
scanf("%d",&A[i][j]);
}
}
}
void add(int A[10][10],int B[10][10],int C[10][10])
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
C[i][j] = (A[i][j] + B[i][j]);
}
}
}
void print(int D[10][10])
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
printf("%d ",D[i][j]);
}
printf("\n");
}
}
main()
{
int A[10][10],B[10][10],C[10][10];
read(A);
read(B);
add(A,B,C);
print(C);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment