# Parallel&horizontal lines using loops

**URL:** <https://discourse.processing.org/t/parallel-horizontal-lines-using-loops/29591>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 23, 2021, 10:05pm UTC](https://discourse.processing.org/t/parallel-horizontal-lines-using-loops/29591 "2021-04-23T22:05:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lelapin](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lelapin](https://discourse.processing.org/u/lelapin)\
**Post date:** [April 23, 2021, 10:05pm UTC](https://discourse.processing.org/t/parallel-horizontal-lines-using-loops/29591/1 "2021-04-23T22:05:11Z")

</div>

Hello  
please i need help in my homework:

Exercise: draw random parallel and horizontal lines using loops.The length of each line is a random number between 0 and 44.

Thanks

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 23, 2021, 10:56pm UTC](https://discourse.processing.org/t/parallel-horizontal-lines-using-loops/29591/2 "2021-04-23T22:56:51Z")

</div>

I would use a for loop to make different y positions for your lines.

The x positions will need to differ by a random amount.

You can draw lines with the `line()` function.

You can generate random numbers with the `random()` function.

It is hard to help you more without seeing your code.

Please post your current code for more help.

For more help, post your current code.

You should post your code. Then we can help you more.

Notice that I’ve said you should post your code three times.  
That’s because it’s important. You should post it.

---

<div class="post-metadata">

**Author:** ![lelapin](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lelapin](https://discourse.processing.org/u/lelapin)\
**Post date:** [April 24, 2021, 2:57pm UTC](https://discourse.processing.org/t/parallel-horizontal-lines-using-loops/29591/3 "2021-04-24T14:57:24Z")

</div>

for (int y=0;y\<=height;y=y+6){  
line((int)random(45),y,(int)random(45),y);  
}  
for (int x=0;x\<=width;x=x+12){  
line(x,(int)random(45),x,(int)random(45));

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 24, 2021, 5:07pm UTC](https://discourse.processing.org/t/parallel-horizontal-lines-using-loops/29591/4 "2021-04-24T17:07:01Z")

</div>

Parallel != vertical != horizontal
