Module cs101
!  Purpose:
!    To illustrate I/O of variables of derived data types.
!         based on chapman's example.
IMPLICIT NONE
Integer, Parameter :: num_quiz = 3;
! Declare type cs101student
TYPE :: cs101student
   CHARACTER(len=9) :: rollnum
! add other fields- name, dept, batch, .... here
   INTEGER, Dimension(num_quiz) :: quizmarks
END TYPE cs101student

contains

Logical Function lt_roll(s1, s2, i)
  Type (cs101student), Intent(IN) :: s1, s2
  Integer, Intent(IN) :: i
  lt_roll = llt(s1%rollnum, s2%rollnum)
End Function lt_roll

Logical Function lt_quizi(s1, s2, i)
  Type (cs101student), Intent(IN) :: s1, s2
  Integer, Intent(IN) :: i
  lt_quizi = s1%quizmarks(i) < s2%quizmarks(i)
End Function lt_quizi

Logical Function lt_total(s1, s2, i)
  Type (cs101student), Intent(IN) :: s1, s2
  Integer, Intent(IN) :: i
  Integer :: j, total1, total2
  total1 = 0 ; total2 = 0
  Do j = 1, num_quiz
     total1 = total1 + s1%quizmarks(j)
     total2 = total2 + s2%quizmarks(j)
  End Do
  lt_total = total1 < total2
End Function lt_total

End Module cs101



