-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path2darrays.cpp
More file actions
37 lines (36 loc) · 725 Bytes
/
2darrays.cpp
File metadata and controls
37 lines (36 loc) · 725 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
/*
* 2 DIMENSIONAL ARRAYS
*/
#include <iostream>
using namespace std;
int main()
{
int rows;
int cols;
cout << "Enter rows and cols of 2d array"<<endl;
cin >> rows >> cols;
int arr[rows][cols];
cout << "Enter the elements of the array"<<endl;
for(int i=0;i<rows;i++)
{
for(int j=0;j<cols;j++)
{
cin >> arr[i][j];
}
}
cout << "Entered elements of 2d array"<<endl;
for(int i=0;i<rows;i++)
{
for(int j=0;j<cols;j++)
{
if(j==cols-1)
{
cout << arr[i][j] << endl;
}
else
{
cout << arr[i][j] << " ";
}
}
}
}