-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2DArray.cpp
More file actions
45 lines (29 loc) · 915 Bytes
/
2DArray.cpp
File metadata and controls
45 lines (29 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
using namespace std;
int main()
{
string cars[][3]={{"Mustang","Escape","f2f"},
{"Audi","Tenure","pi3"},
{"Nexa","twuw","34rt"}};
cout << cars[0][0] << endl;
cout << cars[0][1] << endl;
cout << cars[0][2] << endl;
cout << cars[1][0] << endl;
cout << cars[1][1] << endl;
cout << cars[1][2] << endl;
cout << cars[2][0] << endl;
cout << cars[2][1] << endl;
cout << cars[2][2] << endl;
// Rows = sizeof(array)/sizeof(arr[0]) = no of elements in the array
// Columns = sizeof(array[0]/sizeof(array[0][0])) {array[0][0]=first element}
int rows = sizeof(cars)/sizeof(cars[0]);
int columns = sizeof(cars[0])/sizeof(cars[0][0]);
for(int i=0;i<rows;i++)
{
for(int j=0;j<columns;j++)
{
cout << cars[i][j] << " ";
}
}
return 0;
}