need to stop at multiples

I need an easy way to stop my iterations at a certain number plus its multiples so that i can output a specific character every time I reach that value " c " (and multiples). The current example with two multiples Im using works fine but for big tables i want to have a flexible number of multiples I can handle.

Thanks for your help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void print_matrix(int matrix[LENGTH][LENGTH], int c)
{
	int i;
	int j;
	for(j=1; j<=LENGTH; j++)
	{
		for(i=1; i<=LENGTH; i++)
		{cout << matrix[i][j] << " ";
		if(i==c||i==2*c)
			 cout << "| ";
		}
		cout << endl;
		if(j==c||j==2*c)
			cout << "----------------------" << endl;
	}
}
Have a look at the modulus operator (%)

It's on this page in the "Arithmetic operator" section
http://www.cplusplus.com/doc/tutorial/operators/

Andy
Topic archived. No new replies allowed.