C Programming Code Examples C > Arrays and Matrices Code Examples C Programming Code - Addition of All Elements in Matrix C Programming Code - Addition of All Elements in Matrix #include<stdio.h> int main() { int y, x, mat[10][10], row, col; int sum = 0; printf("\nEnter the number of Rows : "); scanf("%d", &row); printf("\nEnter the number of Columns : "); scanf("%d", &col); //Accept the Elements in Matrix for (y = 0; y < row; y++) { for (x = 0; x < col; x++) { printf("\nEnter the Element mat[%d][%d] : ", y, x); scanf("%d", &mat[y][x]); } } //Addition of all Elements for (y = 0; y < row; y++) { for (x = 0; x < col; x++) { sum = sum + mat[y][x]; } } //Print out the Result printf("\nSum of All Elements in Matrix : %d", sum); return (0); }