5.4) Decisions Within Decisions (cont'd)
I hope you can see now why it is so important to indent when you do if statements
since it makes it clearer where each if statements
start and end.
program example12 real :: a real :: b a=10.0 b=5.0 if ( a > b ) then print *, ‘a is greater than b’ a=b if ( a > 3.0 ) then print *, 'a is greater than 3.0' endif else print *, ‘increase the value of a’ a=40.0 print *, ‘try a value of ‘, a endif end program example12
Example of a program with nested if statements
. Nested means if statements
inside of if statements
. The nested if statement
is on lines 9, 10, and 11.