9Functions - Revisiting SELECT CASE statement PROGRAM...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Revisiting SELECT CASE statement PROGRAM test_sel_case IMPLICIT NONE REAL:: num1 = 3.5//WHAT IS WRONG HERE? It can not be real. temp SELECT CASE (num1) CASE(1:5) WRITE(*,*) ‘it is between 1 and 5’ CASE DEFAULT WRITE(*,*) ‘default case’ END SELECT temp END PROGRAM test_sel_case
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Revisiting SELECT CASE statement PROGRAM test_sel_case2 IMPLICIT NONE INTEGER:: num1 = 5 temp SELECT CASE (num1) CASE(1,3,5,7,9) WRITE(*,*) ‘it is odd’ CASE (2,4,6,8,10) WRITE(*,*) ‘it is even’ CASE(11:) WRITE(*,*) ‘value is too high’ CASE DEFAULT WRITE(*,*) ‘the value is negative or zero’ END SELECT temp END PROGRAM test_sel_case
Background image of page 2
Default variable types – If name starts with letters I through N, it is integer – All others real – Index = 5.3 – P1 = Index/2 Changing default variable types – We can override these defaults. – IMPLICIT INTEGER (a-n, I, z) IMPLICIT NONE disables all these default types. You must declare all variables before using, if program
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

9Functions - Revisiting SELECT CASE statement PROGRAM...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online