#include <stdio.h> #define SARAKKEITA 3 double alkioiden_summa(double mat[][SARAKKEITA], int riveja) { int i,j; double summa=0; for (i=0; i<riveja; i++) for (j=0; j<SARAKKEITA; j++) summa +=mat[i][j]; return summa; } int main(void) { double s2,s3, mat2[2][SARAKKEITA] = { {1,2,3},{4,5,6} }, mat3[3][SARAKKEITA] = { {1,0,0},{0,1,0},{0,0,1} }; s2 = alkioiden_summa(mat2,2); s3 = alkioiden_summa(mat3,3); printf("Summat on %5.2lf ja %5.2lf\n",s2,s3); return 0; }