Q. 17. Write a program that accepts as input a number F that represents temperature in degrees Fahrenheit, converts that number to its equivalent in degrees centigrade, and outputs the converted number.

Solution.
REAL F, C
READ *, F
C =(5/9) * (F - 32)
PRINT *, 'DEGREES CENTIGRADE = ' , C
STOP
END

Q. 18. Write a program that reads values for the three sides of a triangle, calculates its perimeter and its area, and outputs these values.

Solution.
REAL A, B, C
REAL P, S, AREA

READ *, A, B, C

P = A + B + C
S = P/2
AREA = SQRT(S*(S-A)*(S-B)*(S-C))

PRINT *, 'PERIMETER = ', P
PRINT *, 'AREA = ', AREA

STOP
END



Main Contents Page

© Universal Teacher Publications