lol ok guys im a beginner at this so please dont laugh
im having problems with this assignment
its involving two dimensional arrays, now ive gotten the first part of the assignment to work, which is simply printing out a table with the rainfall, and the regions(i will show a sample output)...
Region May Jun Jul Aug Sep Oct
-------------------------------
Ottawa 5 11 5 25 9 5
Toronto 8 10 7 30 5 3
London 7 6 11 27 9 7
60
63
67
ok now for the explination, the data in the table is simply the rainfall which is a two dimensional array, the regions are also a two dimensional array,
the problem is beneith the table the 3 values are the sums, now the problem im having is putting them in the table, heres a sample of my code
Code:
#include <stdio.h>
#define MONTH 6
#define REGION 3
void printresult(const int rainfall[][], char Region[][]);
int sumof(const int rainfall[][]);
int main()
{
int column=0,row=0, sum=0;
const int rainfall[REGION][MONTH]=
{
{5,11,5,25,9,5},
{8,10,7,30,5,3},
{7,6,11,27,9,7},
};
char Region[REGION][80]={" Ottawa","Toronto"," London"};
int ADD[REGION][1];
printresult(rainfall,Region);
sumof(rainfall);
return 0;
}
void printresult(const int rainfall[REGION][MONTH], char Region[REGION][80])
{
int row=0, column=0;
printf(" Region May Jun Jul Aug Sep Oct\n");
printf(" -------------------------------\n");
for(row=0;row<REGION;row++)
{
for(column=0;column<80;column++)
printf("%c", Region[row][column]);
for(column=0;column<MONTH;column++)
printf(" %d ", rainfall[row][column]);
printf("\n");
}
}
int sumof(const int rainfall[REGION][MONTH])
{
int sum=0,row=0, column=0;
for(row=0;row<REGION;row++)
{
for(column=0;column<MONTH;column++)
sum+= rainfall[row][column];
printf("%d", sum);
printf("\n");
sum = 0;
}
return sum;
}
now im pretty sure i gotta declare anotehr 2 dimensional array, and fill it with the sum, and print it out with my printresult function, but i cant figure out how to do that
please any help would be greatly appreciated