File: case_02.f90

package info (click to toggle)
lfortran 0.59.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 56,736 kB
  • sloc: cpp: 168,052; f90: 74,272; python: 17,537; ansic: 7,705; yacc: 2,345; sh: 1,334; fortran: 895; makefile: 37; javascript: 15
file content (97 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
program case_02
    implicit none

    ! local variable declaration
    integer :: marks, out
    marks = 81

    select case (marks)

       case (91:100)
          out = 0
          print*, "Excellent!"

       case (81:90)
          out = 1
          print*, "Very good!"

       case (71:80)
          out = 2
          print*, "Well done!"

       case (61:70)
          out = 3
          print*, "Not bad!"

       case (41:60)
          out = 4
          print*, "You passed!"

       case (:40)
          out = 5
          print*, "Better try again!"

       case default
          out = 6
          print*, "Invalid marks"

    end select
    print*, "Your marks are ", marks

    if (out /= 1) error stop

    ! case default at the top
    select case (marks)

       case default
          print*, "Invalid marks"

       case (91:100)
          print*, "Excellent!"

       case (81:90)
          print*, "Very good!"

       case (71:80)
          print*, "Well done!"

       case (61:70)
          print*, "Not bad!"

       case (41:60)
          print*, "You passed!"

       case (:40)
          print*, "Better try again!"

    end select
    print*, "Your marks are ", marks

    ! case default in the middle
    select case (marks)

       case (91:100)
          print*, "Excellent!"

       case (81:90)
          print*, "Very good!"

       case default
          print*, "Invalid marks"

       case (71:80)
          print*, "Well done!"

       case (61:70)
          print*, "Not bad!"

       case (41:60)
          print*, "You passed!"

       case (:40)
          print*, "Better try again!"

    end select
    print*, "Your marks are ", marks

end program