Q. 27. Write a program that reads a 2 * 3 matrix
column-wise and print it row-wise.
Solution.
INTEGER M(2,3)
READ (5,70) M
WRITE (6, 80) ( (M(I,J) ,J-1,3 ,I=1 ,2) 70 FORMAT*2I3)
80 FORMAT(3(1x,I3))
END
Q. 28. Write a program that prints the monthly
report of activity in a bank account from a set of
input data. The first line (card) of input data provides
the opening balance. All other lines (cards) contain
a transaction code (1= deposit, 2= withdrawal, 0 =
no more transactions), a six-digit date (in the form
DDMMYY), and the amount of transaction.
Solution.
INTEGER CODE, DATE
REAL BALNCE, AMOUNT
READ *, BALNCE
PRINT *, ' ', BALNCE
10 READ *, CODE, DATE, AMOUNT
IF (CODE .EQ. 0) THEN
STOP
ELSE IF (CODE .EQ. 1) THEN
BALNCE = BALNCE + AMOUNT
PRINT *, 'DEP', DATE, AMOUNT, BALNCE
ELSE IF (CODE .EQ. 2) THEN
BALNCE= BALNCE - AMOUNT
PRINT *, 'WDR', DATE, AMOUNT, BALNCE
ELSE
PRINT *, 'INALID CODE READ'
ENDIF
GO TO 10
END
|