Skip to content

Instantly share code, notes, and snippets.

@YassineBajdou
Created June 20, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YassineBajdou/97cbe93b99971e0463057d36cce2747c to your computer and use it in GitHub Desktop.
Save YassineBajdou/97cbe93b99971e0463057d36cce2747c to your computer and use it in GitHub Desktop.
Array 2D
#include <iostream>
using namespace std;
int main()
{
// Array declaration and initialization
int arr[3][5] = {{5, 12, 17, 9, 3}, {13, 4, 8, 14, 1}, {9, 6, 3, 7, 21}};
// Iterate over the array
for(int i=0; i<3; i++)
{
for(int j=0; j<5; j++)
{
// Print out each element
cout << arr[i][j];
}
// Print new line character after the row is printed in above loop
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment