two-dimensional array !!??

Hi,

This prpgram seems to be easy but I couldn't do it!!! so please help me

thank you


Write a program that populates a two-dimensional array in main, sums up the values
of the cells in the array using a second function; and finally prints out the value of the
sum.

1. In the main function: declare a local two-dimensional array with pre-defined
dimensions (HEIGHT, WIDTH)
2. In the main function: populate the two-dimensional array in any manner you
choose
3. Declare a function that takes as parameter the two-dimensional array
populated within the main function. This function should sum all the cells of
the two-dimensional array and return the sum to the main program.
4. The main program should print the sum (returned by the function).
firstly you should take a try, then give us you code and problems you have got.
this is what I've got

but I don't know how to get the total of the cells!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//#include "stdafx.h"
#include <iostream>
#define height 2
#define width 3
using namespace std;


int x,y;

int main ()
{
int eidan[height][width];


for (x=0;x<height;x++)
		for (y=0;y<width;y++)
		{
		cout <<"Enter the value\n";
		cin >> eidan[x][y];
		cout << "\n\n";
		
		}
		
return 0;
}
Last edited on
Topic archived. No new replies allowed.