Sheet 1
Sheet 1
3. Are the following statements legal or illegal? If they are legal, what is their
result? If they are illegal what is wrong with them?
PROGRAM prog1
INTEGER :: i,j
INTEGER, PARAMETER :: K = 4
i = k**2
j = i/k
k = i+j
WRITE(*,*) i,j,k
END PROGRAM prog1
Electrical Department
First Year, 1st Semester
Programming Language (A)
Sheet 1
4. What value is stored in result after the following statements are executed?
INTEGER :: a,c
REAL :: b,result
a = 10
b = 1.5
c = 5
result = FLOOR(a / b) + b * c ** 2
b.
c.
d.
Electrical Department
First Year, 1st Semester
Programming Language (A)
Sheet 1
6. Write a Fortran program that asks the user for his name and greets him with his
name.
7. Write a Fortran program that reads two numbers and prints the sum (addition),
multiply, subtract, divide and remainder of the two numbers.
8. Write a Fortran program to find the third angle of a triangle if two angles are
given.
9. Write a Fortran program that takes three numbers as input to calculate and print
the average of the numbers
10. Write a Fortran program that converts kilometers per hour to miles per hour.
11. Write a Fortran program that reads in the radius and length of a cylinder and
compute volume using the following formulas:
Area = radius * radius * π
Volume = Area * length
12. Write a Fortran program that calculates the equivalent resistance of four
resistors R1, R2, R3, and R4 connected in parallel.
Electrical Department
First Year, 1st Semester
Programming Language (A)
Sheet 1
13. Write a Fortran program that takes hours and minutes as input and calculates
the total number of minutes.
14. Write a Fortran program to convert a given integer (in seconds) to hours,
minutes, and seconds.
15. Write a Fortran program to add two 4-bit binary numbers. (*)
17. Rewrite the previous program without using third variable. (*)
18. Write a Fortran program that accepts an employee's ID, total worked hours of a
month and the amount he received per hour. Print the employee's ID and salary
(with two decimal places) of a particular month. (*)
19. Write a Fortran program to compute the distance between two points on the
surface of earth.
20. Write a Fortran program that reads the coefficients a, b, and c of a quadratic
equation: 𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0 and displays its solution.