Write a ‘C’ Program to calculate sum of elements of a mXn matrix


#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],i,j,m,n,sum=0;
clrscr();
printf("\nEnter the 3*3 matrix=");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{

scanf("%d",&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum=sum+a[i][j];
}
}
printf("\nsum of elements of matrix is=%d",sum);
getch();
}
/* Output
Enter the 3*3 matrix=
1 2 3
4 5 6
7 8 9
sum of elements of matrix is=45 */