Need help with an Array Code.


Ok so i need to ask the user for rows and columns for the array, it should be
between 2 and 50. Then I have to fill the array with random numbers; The
program will then ask the user to provide a user to provide a file name, the
file name will be used to open a file, for output, with this name.
heres my program:

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include<fstream>
using namespace std;
int RowTest();
int ColumnTest(); 
ArrayFiller();

int main()
{
 int Row , Column;
 int Array[Row][Column];
 int i , k;
 
 return(0);
}
int rowtest()
{
 int Row;
 cout << " Please enter a value for the row of the array that is between 2 and 50. \n";
 cin >> Row ;
 while ( 2 >= Row || Row >= 50 )
 {
  cout << " Invalid input, please try again \n";
 }
 
}
return( Row );

int ColumnTest()
{
 int Column;
 cout << " Please enter a value for the column of the array that is between 2 and 50 as well.\n";
 cin >> Column;
 while ( 2 >= Column || Column >= 50 )
 {
  cout << " Invalid input, please try again \n";
 }

}
return ( Column );

int Arrayfiller()
{
 for ( i = 0; i < Row; i++ )
  for ( k = 0; k < Column; k++)
  {
    output << Array[i][k] = rand() % 100 ;
  }

}
return( ArrayFiller )

am I doing it correctly ?
im not too sure what I'm doing.;/
Last edited on
Even if your code performed the way that you want it, the program will/should not compile as is. On line 4, your function declarations should be on separate lines and all end with a semicolon, that is:

int RowTest();
int ColumnTest();
int ArrayFiller();

Personally that is where I would start, gettting the program to compile. Then I would probably use a debugger to check values of variables if I had any logic errors.
Topic archived. No new replies allowed.