Si të krijojmë një tabelë me vlera ta shtuara dhe të gjejmë shumën sipas radhës dhe sipas kolonave.
#include <stdio.h>
main()
{
int sum=0,j,i,A[5][7]={{0,0,0,0,0,0,0},
{1,1,1,1,1,1,1},
{2,2,2,2,2,2,2},
{3,3,3,3,3,3,3},
{4,4,4,4,4,4,4}};
clrscr();
sum=0;
for(i=0; i<=4; i++)
{
for(j=0; j<=6; j++)
printf(“%6i”,A[i][j]);
printf(“\n”);
}
printf(“\n\n\t\t\tShuma sipas radhes\n”);
for(i=0; i<=4; i++)
{ sum=0;
for(j=0; j<=6; j++)
sum=sum+A[i][j];
printf(“\t\t\t\tNo %i: sum=%i”,i+1,sum);
printf(“\n”);
}
printf(“\n\n\t\t\tShuma sipas kolonave\n”);
sum=0;
for(j=0; j<=6; j++)
{
sum=0;
for(i=0; i<=4; i++)
sum=sum+A[i][j];
printf(“\t\t\t\tNo %i: sum=%i”,j+1,sum);
printf(“\n”);
}
}
[cite]