please be specific and simple make like it a biggner wrote it not a professional
We want to play with Fortran a little.
Also need an answers.txt to explain what happens.
1. Try to change a literal value in a function.
2. Write function which checks for pass by reference.
3. Try using a mixed datatype expression.
4. Create a 4D or 5D array and make sure it works.
5. Create a recursive function and record what happens.
*. See if you can trick into really doing recursion.
PROGRAM count
DO 50 i = 1, 10
PRINT *, 'Number', i
50 CONTINUE
END
DIMENSION MYARR (10, 20, 5)
MYARR(1, 1, 1) = 5
MYARR(10, 20, 5) = 5000
PRINT *, MYARR(1, 1, 1)
SUBROUTINE name (parameters)
whatever code
RETURN
END
Originally Fortran
square(7)
print 7 ----> Could print 49
PROGRAM FUN
CALL ADD(4, 5)
END
SUBROUTINE ADD (X, Y)
ANS = X + Y
PRINT *, ANS
RETURN
END
[charon] vi myfunfortran.f
[charon] g77 myfunfortran.f
[charon] ./a.out
DO 50 I = 1, 10
DO50I = 1,10 // This is the start of our loop
DO50I = 1.10 // This sets var DO50I to be 1.1
DO50I = 1.10 // This sets var DO50I to be 1.1
Note that since all space is ignored and variables are implicitly
declared, this statement sets DO50I without any warnings or errors.
There are dangers in allowing implicit variable declarations (like in
Fortran), such as a typo which creates a whole new variable without
any warnings or errors (meaning it is still a logic error but the
compiler won't notify the programmer about the typo).
SUBROUTINE ADD (X, Y)
TMP = X
X = Y
Y = TEMP
RETURN
END
Fortran had an Arithmetic IF which was a 3 way IF statement which
selected the appropriate choice based on the test begin less than,
equal, or greater than zero.
IF (X) s1, s2, s3
IF (X) Y = Y + 10, Y = Y - 1, Y = Y - 1
Before long programmers saw that a more conventional Logical IF
(with only true/false) would be easier and more useful.
IF (X .GT. 0) Y = Y + 10
IF (X .LE. 0) GOTO 100
Y = Y + 10
GOTO 200
100 Y = Y - 1
200 ...