{"id":"9051e9ea-0b68-4e7c-b262-236d1f270597","name":"2d Arrays Demo","description":"1. You are given a number n, representing the number of rows.\r\n2. You are given a number m, representing the number of columns.\r\n3. You are given n*m numbers, representing elements of 2d array a.\r\n4. You are required to display the contents of 2d array as suggested by output format below.","inputFormat":"A number n\r\nA number m\r\ne11\r\ne12..\r\ne21\r\ne22..\r\n.. n * m number of elements","outputFormat":"e11 e12 e13 ..\r\ne21 e22 e23 ..","constraints":"1 &lt;= n &lt;= 10^2\r\n1 &lt;= m &lt;= 10^2\r\n-10^9 &lt;= e1, e2, .. n * m elements &lt;= 10^9","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\nint main(){\r\n\r\n \r\n //write your code here\r\n return 0\r\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n // write your code here \r\n }\r\n }"},"python":{"code":"def main():\r\n #write your code here\r\nif __name__ == \"__main__\":\r\n main()"}},"points":10,"difficulty":"easy","sampleInput":"2\r\n4\r\n11\r\n12\r\n13\r\n14\r\n21\r\n22\r\n23\r\n24","sampleOutput":"11 12 13 14\r\n21 22 23 24","questionVideo":"https://www.youtube.com/embed/aN9zP9M_FZ8","hints":[],"associated":[{"id":"871cd8b0-56e8-4532-ab50-e12cdbb1c8ad","name":"How does 2D Array store data?","slug":"how-does-2d-array-store-data","type":4},{"id":"8badb44f-1363-4336-bc0d-a96655d9d5a9","name":"Can we use a 2D array as a 1D array?","slug":"can-we-use-a-2d-array-as-a-1d-array","type":4},{"id":"c8ed05d2-0dc7-470f-98f0-078cf2d81233","name":"Difference between 1D Array and 2D Array?","slug":"difference-between-1d-array-and-2d-array","type":4},{"id":"e225c152-3649-4786-bf16-ed30cd430b69","name":"In what manner we can use loops so that we can easily add data in 2D and print data from a 2D array?","slug":"in-what-manner-we-can-use-loops-so-that-we-can-easily-add-data-in-2d-and-print-data-from-a-2d-array","type":4},{"id":"ea3ed490-3911-4892-9ace-ea174b139093","name":"How we can iterate over the 2D array","slug":"how-we-can-iterate-over-the-2d-array","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f185374c-5448-476e-93e8-c4a4e9d1d520","name":"2D Arrays","slug":"2d-arrays-9999","type":0},{"id":"3fe9a7e4-bb2a-4fc5-9905-fae83e2f2d65","name":"2d Arrays Demo","slug":"2d-arrays-demo","type":1}],"next":{"id":"bb2ced46-16da-4aac-bb90-06fe777ce474","name":"2D Arrays Demo","type":3,"slug":"2d-arrays-demo"},"prev":{"id":"02d66dce-2010-43f6-8cef-fc60705ee0ee","name":"Introduction to 2D Array","type":0,"slug":"introduction-to-2d-array"}}}

# 2d Arrays Demo

1. You are given a number n, representing the number of rows. 2. You are given a number m, representing the number of columns. 3. You are given n*m numbers, representing elements of 2d array a. 4. You are required to display the contents of 2d array as suggested by output format below.

{"id":"9051e9ea-0b68-4e7c-b262-236d1f270597","name":"2d Arrays Demo","description":"1. You are given a number n, representing the number of rows.\r\n2. You are given a number m, representing the number of columns.\r\n3. You are given n*m numbers, representing elements of 2d array a.\r\n4. You are required to display the contents of 2d array as suggested by output format below.","inputFormat":"A number n\r\nA number m\r\ne11\r\ne12..\r\ne21\r\ne22..\r\n.. n * m number of elements","outputFormat":"e11 e12 e13 ..\r\ne21 e22 e23 ..","constraints":"1 &lt;= n &lt;= 10^2\r\n1 &lt;= m &lt;= 10^2\r\n-10^9 &lt;= e1, e2, .. n * m elements &lt;= 10^9","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\nint main(){\r\n\r\n \r\n //write your code here\r\n return 0\r\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n // write your code here \r\n }\r\n }"},"python":{"code":"def main():\r\n #write your code here\r\nif __name__ == \"__main__\":\r\n main()"}},"points":10,"difficulty":"easy","sampleInput":"2\r\n4\r\n11\r\n12\r\n13\r\n14\r\n21\r\n22\r\n23\r\n24","sampleOutput":"11 12 13 14\r\n21 22 23 24","questionVideo":"https://www.youtube.com/embed/aN9zP9M_FZ8","hints":[],"associated":[{"id":"871cd8b0-56e8-4532-ab50-e12cdbb1c8ad","name":"How does 2D Array store data?","slug":"how-does-2d-array-store-data","type":4},{"id":"8badb44f-1363-4336-bc0d-a96655d9d5a9","name":"Can we use a 2D array as a 1D array?","slug":"can-we-use-a-2d-array-as-a-1d-array","type":4},{"id":"c8ed05d2-0dc7-470f-98f0-078cf2d81233","name":"Difference between 1D Array and 2D Array?","slug":"difference-between-1d-array-and-2d-array","type":4},{"id":"e225c152-3649-4786-bf16-ed30cd430b69","name":"In what manner we can use loops so that we can easily add data in 2D and print data from a 2D array?","slug":"in-what-manner-we-can-use-loops-so-that-we-can-easily-add-data-in-2d-and-print-data-from-a-2d-array","type":4},{"id":"ea3ed490-3911-4892-9ace-ea174b139093","name":"How we can iterate over the 2D array","slug":"how-we-can-iterate-over-the-2d-array","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f185374c-5448-476e-93e8-c4a4e9d1d520","name":"2D Arrays","slug":"2d-arrays-9999","type":0},{"id":"3fe9a7e4-bb2a-4fc5-9905-fae83e2f2d65","name":"2d Arrays Demo","slug":"2d-arrays-demo","type":1}],"next":{"id":"bb2ced46-16da-4aac-bb90-06fe777ce474","name":"2D Arrays Demo","type":3,"slug":"2d-arrays-demo"},"prev":{"id":"02d66dce-2010-43f6-8cef-fc60705ee0ee","name":"Introduction to 2D Array","type":0,"slug":"introduction-to-2d-array"}}}

Editor

# 2d Arrays Demo

easy

1. You are given a number n, representing the number of rows. 2. You are given a number m, representing the number of columns. 3. You are given n*m numbers, representing elements of 2d array a. 4. You are required to display the contents of 2d array as suggested by output format below.

## Constraints

1 <= n <= 10^2 1 <= m <= 10^2 -10^9 <= e1, e2, .. n * m elements <= 10^9

## Format

### Input

A number n A number m e11 e12.. e21 e22.. .. n * m number of elements

### Output

e11 e12 e13 .. e21 e22 e23 ..

## Example

Sample Input

2 4 11 12 13 14 21 22 23 24

### Sample Output

11 12 13 14 21 22 23 24

Question Video

Discussions

Show Discussion

Related Resources