DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Two-Dimensional Table

05.27.2006
| 10303 views |
  • submit to reddit
        Used for two-dimensional arrays with the nested loops. This example outputs a multiplication table. Ending with 9*9 = 81. Good for general output which must be formatted in a table. 

// Loop used for two-dimensional iterations for a table
// useful for tabular output
 for(int x = 1;x<=9;x++)
 {
 	cout<<endl;
 	for(int i = 1;i<=9;i++)
 	{
   	cout<<"\t"<<x*i;
 	}
 }