May 19, 2013 at 10:23am UTC
Okay, im kinda new to this c++ program and all.
One question is how do you make a 2D array(table) using arrays and functions
eg:
_ _____|______|________________________
0| | |
1| | |
2| | |
3| | |
4| | |
it has a fixed column of 5
and the number of rows(0,1,2,3,4) is determined by the value the user enters...
much appreciated
May 19, 2013 at 10:26am UTC
What do you have problem with? Creating data sructure? Or outputting it? What have you tried?
May 19, 2013 at 8:59pm UTC
I've used a nested for loop to firstly create the table:
but its not outputting what i want...
this is the nested loop im using
#include <iomanip>
#include <cstdlib>
using namespace std;
int main()
{
const int N=7;
int months;
cout<<"Enter number of months:";
cin>>months;
int table[months][N];
for(int i = 0; i<= months;i++)
{
cout<<i<<endl;
for(int j = 0; j < N;j++)
{
cout<<"sector#"<<j;
//cout<<table[i][j]<<endl;
}
}
What i want is to display the rows from 0 to the number the user enters. eg
if he enters 10
then:
0
1
2
3
4
5
6
7
8
9
10
this part is fine
, using a for loop but, i want the table to have just a single column, consisting of 5 elements.
what i want is something like this:
|Title |Title |Title |Title |
---------------------------------
0|
1|
2|
3|
4|
5|
6|
7|
thnax in advance
Last edited on May 19, 2013 at 9:01pm UTC