Hi guys.
I would like to ask a question regarding this code
What will be output of the following program?
INTEGER M,N
M =6
N =8
IF (M.LT.N) THEN
M=M+2
IF (N.LT.M) THEN
PRINT*, M**2, N**2
ELSEIF (M.GT.N) THEN
PRINT*,M+, N+1
ELSE
PRINT*, M+1,N+2
ENDIF
ELSE
PRINT*, M,N,M-N
ENDIF
END
Now the first condition is TRUE so M new value will be M=6+2 =8
So when I move on to the next condition am I going to consider M as 6 or 8?
Copyright © 2024 Q2A.ES - All rights reserved.
Answers & Comments
Verified answer
M has changed, so it is now 8. That is the value that has to be used from that point on.
The output statement that will ultimately be executed would be
PRINT*, M+1,N+2
and with the current values, that would put out 9 and 10