# New to Arrays, help making a simple less than 10 lines code

**URL:** https://discourse.processing.org/t/new-to-arrays-help-making-a-simple-less-than-10-lines-code/43147
**Category:** Beginners
**Created:** [November 5, 2023, 3:10am UTC](https://discourse.processing.org/t/new-to-arrays-help-making-a-simple-less-than-10-lines-code/43147 "2023-11-05T03:10:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![beginn](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@beginn](https://discourse.processing.org/u/beginn)
#### Post date: [November 5, 2023, 3:10am UTC](https://discourse.processing.org/t/new-to-arrays-help-making-a-simple-less-than-10-lines-code/43147/1 "2023-11-05T03:10:18Z")

</div>

Create an array of size 100 and fill it up with random numbers using a loop. Using a loop print all the numbers located at the “odd” indexes (i.e. numbers located at [1], [3], [5] etc.) of the array.

I have–  
int array = new int [100];

then I feel like it should have–  
for (int i=0; i\<100; i++) {

Then what?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [November 5, 2023, 3:14am UTC](https://discourse.processing.org/t/new-to-arrays-help-making-a-simple-less-than-10-lines-code/43147/2 "2023-11-05T03:14:19Z")

</div>

> **[random() / Reference](https://processing.org/reference/random_.html)**
>
> Generates random numbers. Each time the random() function is called, it returns an unexpected value within the specified range. If only one parameter is passed to the function, it will return a…

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [November 5, 2023, 5:50am UTC](https://discourse.processing.org/t/new-to-arrays-help-making-a-simple-less-than-10-lines-code/43147/3 "2023-11-05T05:50:06Z")

</div>

> **[floor() / Reference](https://processing.org/reference/floor_.html)**
>
> Calculates the closest int value that is less than or equal to the value of the parameter.

> **[% (modulo) / Reference](https://processing.org/reference/modulo.html)**
>
> Calculates the remainder when one number is divided by another. For example, when 52.1 is divided by 10, the divisor (10) goes into the dividend (52.1) five times (5 \* 10 == 50), and there is a remain…

> **[Odd or Even number - Processing Forum](https://forum.processing.org/one/topic/odd-or-even-number.html)**
>
> Processing Forum

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [November 5, 2023, 12:54pm UTC](https://discourse.processing.org/t/new-to-arrays-help-making-a-simple-less-than-10-lines-code/43147/4 "2023-11-05T12:54:21Z")

</div>

Hello @beginn,

> [@beginn](#):
>
> Then what?

Take a step back before taking a step forward.  
What’s first?

Read and follow the guidelines listed here before posting and asking questions:  
[Welcome to the Processing Foundation Discourse](https://discourse.processing.org/t/welcome-to-the-processing-foundation-discourse/8)

Know what resources are available to you.  
The Processing website is a good start and has tutorials, references, examples here:  
[https://processing.org/](https://processing.org/)

Next?

Break it down into steps.  
First and foremost learn and understand each point that is asked (you can do a search on site above for each of these):

- array
- loop
- print
- random

Once you understand each of the above take the next step and piece it together.

The odd indices may be a challenge for a beginner. Seek and you shall find.

Another reference:  
[Creative Coding for Beginners - Full Course!](https://www.youtube.com/watch?v=4JzDttgdILQ&t=1800s)  
I linked it to what I consider good advice for a beginner… be sure to start at the beginning.

After all that is said and done try to write the code from scratch to reinforce the concepts you have learned.

`:) `
