# Loops with else

**URL:** https://community.freefem.org/t/loops-with-else/916
**Category:** General Discussion
**Created:** [April 14, 2021, 5:32pm UTC](https://community.freefem.org/t/loops-with-else/916 "2021-04-14T17:32:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Aicha](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aicha](https://community.freefem.org/u/Aicha)
#### Post date: [April 14, 2021, 5:32pm UTC](https://community.freefem.org/t/loops-with-else/916/1 "2021-04-14T17:32:03Z")

</div>

Hi,  
i want to write following conditions with FF++: we suppose that a1\<a2.  
is it true to write:  
for (real t=0, t\<T, t+=dt)  
{  
if (t \< a1) {…}  
else if (t\>a1)&(t\<a2) {…instructions…}  
else if (t \> a1) & (t\>a2) {…instructions…}  
}  
?

Regards

---

<div class="post-metadata">

### Author: ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)
#### Post date: [April 15, 2021, 7:53am UTC](https://community.freefem.org/t/loops-with-else/916/2 "2021-04-15T07:53:43Z")

</div>

I think you should use the logical and: `&&` so

> if (t \< a1) {…}  
> else if ((t\>a1)&&(t\<a2)) {…instructions…}  
> else if ((t \> a1) && (t\>a2)) {…instructions…}

alternatively you can write

> if (t \< a1) { instruction here t\<a1}  
> else{ here t\>=a1  
> if (t\<a2) {…instructions…here t\>=a1 and t\<a2}  
> else {…instructions…here t\>=a1 and t\>=a2}  
> }

I hope this helps
