best practice for nested if stements ie - if x is true and y is true, then...
Hi all. I have a basic question about syntax for nested if statements and use of brackets.
Let's say I want to perform the following logic...
If a is greater than b , and a is also greater than c , then let x equal a.
Here is the code I have tried with no brackets.
Code:
if(a > b) if (a > c) x = a;
Here is the code using brackets:
Code:
if(a > b)
{
if(a > c) x = a;
}
Will these two produce different results?
The answer is not obvious with my searches, but on-line compilers seem to work either way. I will be using this in GCC for embedded. Thanks for your help ?
Cheers,