+ 3

If operations

When joining more than one if operation, does one have to put brackets around the different "if" operations?

14th Mar 2018, 12:20 PM
arbaaz
5 ответов
+ 8
no need to put brackets , it U only want to execute a single statement if if () condition evaluates to true //Hatsy done right thing by using && same set of statement(s) are executing in the code having 2 if () statements //can be written as :: if (x > 30) if (x < 60) // do something //can simply be if (x > 30 && x < 60) // do something
14th Mar 2018, 12:58 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 7
Really depends on what you want to do, or what you mean by "joining more than one if operation". int x = 56; if (x > 30) { if (x < 60) { // do something } } can simply be if (x > 30 && x < 60) { // do something }
14th Mar 2018, 12:32 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
In the programming language Python.
14th Mar 2018, 6:07 PM
arbaaz
+ 2
Thank you all for your answers.
14th Mar 2018, 6:08 PM
arbaaz
+ 1
In which language ?
14th Mar 2018, 12:29 PM
Hylectrif
Hylectrif - avatar