Need some help with a program

I need some help with writing a function/module for the following program that passes in both parameters (number of rows and columns), I also need to get it so that it doesn't have a print command start a new line.

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
#include <iostream>
#include <string>

using namespace std;

int main()
{
	//Declaration Block
	int numRows = 0;
	int numCols = 0;

	cout << "Enter how many columns you want your table to have: ";
	cin >> numCols; 

	cout << "Enter how many rows you want your table to have: ";
	cin >> numRows;

	for (int i = 0; i < numRows; i++)
	{
		for (int j = 0; j < numCols; j++)
		{
			cout << " Row " << i + 1 << "\t" << " Column " << j + 1;
		}
		cout << endl;
	}

	system("pause");
	return 0; 
}
Last edited on
Bump
Hello aaronf89,

You can start with this:
http://www.cplusplus.com/doc/tutorial/functions/

Eventually you will put your nested for loops inside the {} of the function.

I also need to get it so that it doesn't have a print command start a new line.

Not sure what you mean here. The output you have looks good.

Hope that helps,

Andy
Topic archived. No new replies allowed.