Two-Dimensional Array Manipulation in C++
By: Ignatius
This simple C++ program shows how to manipulate a two dimensional array. In this case it will traverse through the array and print its contents.
#include <iostream>
using namespace std;
#define m 3
#define n 3
int main(void)
{
int i, j;
int x[m][n]={{10,25,33}, {21,32,43},{20,42,51}};
cout<<"\n3x3 arrays' subscripts and\n";
cout<<"their respective elements\n";
cout<<"--------------------------\n";
// outer for loop, reading the row by row...
for(i=0; i<m; i++)
// inner loop, for every row, read every column by column...
for(j=0; j<n; j++)
cout<<"["<<i<<"]"<<"["<<j<<"]"<<"="<<x[i][j]<<"\n";
return 0;
}
Archived Comments
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Calculating total based on the given quantity and price in C++
Sorting an array of Strings in C++
Matrix using nested for loops in C++
Compute the square root of the sum of the squares of an array in C++
Calculate average using Two-Dimensional Array in C++
Two-Dimensional Array Manipulation in C++
Compiling and Linking Multiple Source Files in C++
Escape Sequences for Nonprintable Characters in C++
Using the Built-in Arithmetic Types in C++