So heres a portion of my program... the program has several functions (each doing diff. things)
Im having a problem I can not find the way to write the sum of the third row in costOfSports array.
the book says something like this:
for(col=0;col<5;col++)
{
for(row=0;row<3;row++)
{
row_sum[row]=array[row][col];
}
}
//but it is not working... it does not generate bugs but it gives me an "address" instead of a number...
what can I do? any hint? trick? code? thanks to everyone :)
#include<iostream>
using namespace std;
int main()
{
const int NUM_SCHOOLS=5;
const int NUM_SPORTS=3;
enum SportType {FOOTBALL,BASKET,VOLLEYBALL};
int kidsInSports[NUM_SCHOOLS][NUM_SPORTS]={{5,7,10},
{2,5,1}, {20,37,3},
{40,2,5},
{10,8,5}}; {40,2,5},
{10,8,5}};
int costOfSports[NUM_SPORTS][NUM_SCHOOLS]={{25,30,45,50,55},
{5,50,10,25,8},
{13,70,25,47,5}};
int row,col;
int col_sum[5]={0},row_sum[3]={0};
double sum;
cout<<endl;
//THIS IS THE part im having problems with...
cout<<"the sum is"<<' ';
for(row=0;row<3;row++)
{
for(col=0;col<5;col++)
{
row_sum[3]+=costOfSports[row][col];
}
system("PAUSE");
return 0;
}
}