Fortran: Lesson 2

Lesson topics


View Demos
# 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10
Download Demos
# 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10

Demo 8

								        program demo
c       This program demonstrates how character lengths work.
c       Try entering words of different lengths and see what happens.
c       Then delete *5 after "word" in the character declaration,
c       and compile and run the program again.
        character word*5, ans*1

 1      print *, "Please enter your word : "
        read *, word
        print *
        print *, "The word you entered was : ", word
        print *

        print *, "Do you want to enter another word ? (y or n)"
        read*, ans
        print*
        if (ans .eq. "y" .or. ans .eq. "Y") go to 1
        print *, "OK, Bye"
        end