for loop table

(First of all , apologize for any mistake in english writing)
Good day, I need some tips/help printing out a table into the console , using a for loop, what i want is something to be print out , something like this :

| ms[a]| ms [a]| ms[a] | ms[a] |
--------------------------------
| ma[a]| ma[a] | ma[a] | ma[a] |

or something in this way, what could i do ? i have so far this loop:

1
2
3
4
5
6
7
for (int a=0; a<10; a++)
	{
		cout<< "| "<<ms[a]<<" |";	
	
	}


Last edited on
Hello Nickoblack,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can us the preview button at the bottom to see how it looks.

See the links for an explaination of how to use the code tags. I think you missed the closing code tag ([/code]).

For what you want your output to look like I would suggest this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
std::cout << "| ";  // <--- To print once B4 the loop.

for (int a = 0; a < 10; a++)  //  To print the ms array.
{
	cout << ms[a] << ", ";
}

std::cout << "|" << std::endl;  // <--- To print once after the loop.

std::cout << "-----------------------------" << std::endl;  // <--- Adjust number of dashes as needed.

std::cout << "| ";

for (int a = 0; a < 10; a++)  //  To print the ma array.
{
	cout << ma[a] << ", ";
}

std::cout << "|" << std::endl;


Hope that helps,

Andy
Topic archived. No new replies allowed.