- Fortran Tutorial
- Fortran - Home
- Fortran - Overview
- Fortran - Environment Setup
- Fortran - Basic Syntax
- Fortran - Data Types
- Fortran - Variables
- Fortran - Constants
- Fortran - Operators
- Fortran - Decisions
- Fortran - Loops
- Fortran - Numbers
- Fortran - Characters
- Fortran - Strings
- Fortran - Arrays
- Fortran - Dynamic Arrays
- Fortran - Derived Data Types
- Fortran - Pointers
- Fortran - Basic Input Output
- Fortran - File Input Output
- Fortran - Procedures
- Fortran - Modules
- Fortran - Intrinsic Functions
- Fortran - Numeric Precision
- Fortran - Program Libraries
- Fortran - Programming Style
- Fortran - Debugging Program
- Fortran Resources
- Fortran - Quick Guide
- Fortran - Useful Resources
- Fortran - Discussion
Fortran - nested select case construct
You can use one select case statement inside another select case statement(s).
Syntax
select case(a) case (100) print*, "This is part of outer switch", a select case(b) case (200) print*, "This is part of inner switch", a end select end select
Example
program nestedSelectCase ! local variable definition integer :: a = 100 integer :: b = 200 select case(a) case (100) print*, "This is part of outer switch", a select case(b) case (200) print*, "This is part of inner switch", a end select end select print*, "Exact value of a is : ", a print*, "Exact value of b is : ", b end program nestedSelectCase
When the above code is compiled and executed, it produces the following result −
This is part of outer switch 100 This is part of inner switch 100 Exact value of a is : 100 Exact value of b is : 200
fortran_decisions.htm
Advertisements