SUM OF ELEMENTS OF A MATRIX
#include <stdio.h>
void main()
{
int
m[5][5],r,c,i,j,s=0;
printf("How
many rows and cols");
scanf("%d%d",&r,&c);
printf("enter
elements");
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{
scanf("%d",&m[i][j]);
s=s+m[i][j];
}
printf("sum of elements =%d",s);
22
}
OUTPUT
How many rows and cols 2
4
Enter elements 1
2
3
4
5
6
7
8
Sum of elements 36
No comments:
Post a Comment