逻辑运算符'.or.'的操作数 at(!)是逻辑(4)/ CHARACTER(1)

Vis*_*n C 1 fortran gfortran

我有以下代码:

print*,"type s for a square and type t for a triangle"
read*,fig
if(fig =='t' .or. 'T') then
print*,"Enter the sides of the triangle"
read*,a,b,c
area=tri(a,b,c)
print*,"The area of the triangle is",area
else if (fig=='s' .or.'S') then 
print*,"Enter the side of the square"
read*,s
area=sq(s)
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

intro_fun.f:9:24:

  if(fig == 't' .or. 'T') then
                        1
Error: Operands of logical operator '.or.' at (1) are LOGICAL(4)/CHARACTER(1)
intro_fun.f:14:27:

  else if(fig=='s' .or. 'S') then
                           1
Error: Operands of logical operator '.or.' at (1) are LOGICAL(4)/CHARACTER(1)
Run Code Online (Sandbox Code Playgroud)

alb*_*ert 5

您正在使用该声明:

if(fig == 't' .or. 'T') 这应该是:

if(fig == 't' .or. fig == 'T')