FORTRAN 95 2. (Convert to Lowercase) The ASCII Table call associates characters
ID: 3755910 • Letter: F
Question
FORTRAN 95
2. (Convert to Lowercase) The ASCII Table call associates characters with integers between 0 and 127, which are representable in binary form using 7 bits. Read about this in more detail on the Wikipedia page on the subject https://en.wikipedia.org/wiki/ASCII. The FORTRAN language implements this association through the intrinsic functions CHAR, ICHAR and IACHAR. You can
note that the codes associated with the letters 'a' through 'z' are, respectively, translations of the codes associated with the letters 'A' through 'Z'. Review the output of the following program:
program converte_up
character :: ca
print *, iachar ('A'), iachar ('a')
print *, 'Provide a MAIUSCLE character'
read *, ca
print *, ca, char (iachar (ca) + iachar ('a') - iachar ('A'))
end program converte_lower
REQUEST: Create a function in FORTRAN 95 to convert a STRING to lowercase characters. It should be called stm = minuscule (st). Complete the template below:
FUNCTION lower (st1) RESULT (st2)
CHARACTER (*) :: st1
CHARACTER (LEN (st1)) :: st2
------- complete here
END FUNCTION lower
Explanation / Answer
program convert_up
character(100) :: line
character(100) :: stm
print *, 'Enter String'
read *, line
print *, lower(line)
end program convert_up
FUNCTION lower (st1) RESULT (st2)
CHARACTER (*) :: st1
CHARACTER (LEN (st1)) :: st2
CHARACTER :: c
integer ::i
i=1
st2=""
do while(i<=len_trim(st1))
c=st1(i:1)
c=char (iachar (c) + 32)
st2=st2//c
end do
END function lower
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.