Program
#include<stdio.h>
int sum(int [10][10]);
int i, j, row, col;
void main()
{
int mat[10][10] ;
int s;
printf("Enter the order of the matrix : ") ;
scanf("%d %d", &row, &col) ;
printf("\nEnter the elements of the matrix : \n\n") ;
for(i = 0 ; i < row ; i++)
for(j = 0 ; j < col ; j++)
scanf("%d", &mat[i][j]) ;
s=sum(mat);
printf("\nThe sum of the elements in the matrix is : %d",s) ;
}
int sum(int matrix[10][10])
{
int sum=0;
for(i = 0 ; i < row ; i++)
for(j = 0 ; j < col ; j++)
sum = sum + matrix[i][j] ;
return sum;
}
#include<stdio.h>
int sum(int [10][10]);
int i, j, row, col;
void main()
{
int mat[10][10] ;
int s;
printf("Enter the order of the matrix : ") ;
scanf("%d %d", &row, &col) ;
printf("\nEnter the elements of the matrix : \n\n") ;
for(i = 0 ; i < row ; i++)
for(j = 0 ; j < col ; j++)
scanf("%d", &mat[i][j]) ;
s=sum(mat);
printf("\nThe sum of the elements in the matrix is : %d",s) ;
}
int sum(int matrix[10][10])
{
int sum=0;
for(i = 0 ; i < row ; i++)
for(j = 0 ; j < col ; j++)
sum = sum + matrix[i][j] ;
return sum;
}
No comments:
Post a Comment