#include "stdio.h"
#define ROW 4
#define COL 4
void input_matrix (int, int, int A[][4], int B[][4]);
void add_matrix (int, int, int A[][4], int B[][4], int C[][4]);
void loadidentity_matrix (int, int, int D[][4]);

void main (void)
{
int A[ROW][COL];
int B[ROW][COL];
int C[ROW][COL];
int D[ROW][COL];
int i, j;

input_matrix (ROW, COL, A, B);
add_matrix (ROW, COL, A, B, C);
loadidentity_matrix (ROW, COL, D);

for (i=0; i<ROW; i++)
{
	for (j=0; j<ROW; j++)
	{
		printf ("A[%d][%d]=%d\n", i, j, A[i][j]);
		printf ("B[%d][%d]=%d\n", i, j, B[i][j]);
		printf ("C[%d][%d]=%d\n", i, j, C[i][j]);
		printf ("D[%d][%d]=%d\n", i, j, D[i][j]);
	}
}
}

void input_matrix (int R, int C, int A[][4], int B[][4])
{
	int i, j;
	printf ("Enter values for array A\n");
	for (i=0; i<R; i++)
	{
		for (j=0; j<C; j++)
			scanf ("%d", A[i][j]);
	}

	printf ("Enter values for array B\n");
	for (i=0; i<R; i++)
	{
		for (j=0; j<C; j++)
			scanf ("%d", B[i][j]);
	}
}

void add_matrix (int r, int c, int A[][4], int B[][4], int C[][4])
{
	int i, j;
	for (i=0; i<r; i++)
	{
		for (j=0; j<c; j++)
		{
			if (r==c)
			{
			C[i][j]=A[i][j]+B[i][j];
			printf ("C[%d][%d]=%d\n", i, j, C[i][j]);
			}
		}
	}
}
void loadidentity_matrix (int col, int row, int D[][4])
{
	int i, j;
	for (i=0; i<row; i++)
	{
		for (j=0; j<col; j++)
		{
			if (i==j)
				D[i][j]=1;
			else
				D[i][j]=0;
		}
	}
}

whats wrong with the code? can u help? i get general protection error for this code

Is this for a course or for real use? If you intend to actually use the code - I would highly recommend going with an already developed mathematical toolkit for c++, such as VNL (part of VXL). It will most definitely be very optimized an provide all of the functionalities you are looking for.

scanf ("%d", A[i][j]);

This is what is wrong (hint: scanf needs an address to scan into).