the use of a two-dimensional array
#include <stdio.h>
#define iROWS 4
#define iCOLUMNS 5
int main( )
{
int irow;
int icolumn;
int istatus[iROWS][iCOLUMNS];
int iadd;
int imultiple;
for(irow=0; irow < iROWS; irow++)
for(icolumn=0; icolumn < iCOLUMNS; icolumn++) {
iadd = iCOLUMNS - icolumn;
imultiple = irow;
istatus[irow][icolumn] = (irow+1) *
icolumn + iadd * imultiple;
}
for(irow=0; irow<iROWS; irow++) {
printf("CURRENT ROW: %d\n",irow);
printf("RELATIVE DISTANCE FROM BASE:\n");
for(icolumn=0; icolumn<iCOLUMNS; icolumn++)
printf(" %d ",istatus[irow][icolumn]);
printf("\n\n");
}
return(0);
}
Related examples in the same category