174k views
4 votes
Write a program that will generate random numbers and that numbers will be stored in a two-dimensional array. Then display the generated values on the screen and then also print the even numbers from the generated array elements. Task 1: First of all, you are required to generate random numbers from 1 to 500. For this, you are required to create a function named as “generateArray. The generateArray will load two- dimensional array with random numbers from 1to 500. The size of the two-dimensional array will be 7*7. Task 2: Defined a function named as “showArray(), which will display the elements of the two- dimensional array on the screen. See the sample output. Task 3: The final task is to find the even numbers in this array and display it on the console. For this purpose create a function findEvenNumber().

User Suchit
by
6.3k points

2 Answers

4 votes
Make this shorter
Sorry
User CSRedRat
by
6.8k points
2 votes

Note: You gave no language to use, so I will tell you the best way to do this using python.

First, for generating random numbers, you should import the random module. Create a new file and at the top put the text "import random". Next, to create the function, you will use the def statement. For each function, put def, then space and the name of the function, then enter two brackets and :. Indent the next line. To choose a random number, use the random module's function of randint, which can be found on the docs. Save these inside of a Tuple inside of a list, which could just be called something like numbers. To output them, just use print(numbers). I'm sorry that I can't help you with the third step.

User Salal Aslam
by
6.1k points