fortran 77 example
c00000000111111111122222222223333333333444444444455555555556666666666777
c23456789012345678901234567890123456789012345678901234567890123456789012
program function1
c --- declaration of variables
real x, y
c --- show function
print*,"=========================================="
print*,"Calculate the function y = f(x) defined as"
print*," y = x+1 if x < 1"
print*," y = 2-x if x >= 1"
print*,"=========================================="
c --- request x as input
print*,"enter a value of x:"
read*,x
c --- evaluation of function
if (x.lt.1.0) then
y = x+1
else
y = 2-x
end if
c --- print result
print*,"the corresponding value of y is: ",y
c --- end program
end
c23456789012345678901234567890123456789012345678901234567890123456789012
program function1
c --- declaration of variables
real x, y
c --- show function
print*,"=========================================="
print*,"Calculate the function y = f(x) defined as"
print*," y = x+1 if x < 1"
print*," y = 2-x if x >= 1"
print*,"=========================================="
c --- request x as input
print*,"enter a value of x:"
read*,x
c --- evaluation of function
if (x.lt.1.0) then
y = x+1
else
y = 2-x
end if
c --- print result
print*,"the corresponding value of y is: ",y
c --- end program
end