UNIPORT CSC 280: Answers to Introduction to Computer Programming (Modern FORTRAN) Practical Workbook Part I
CSC 280 Answers to Practical Workbook – Introduction to Computer Programming, Modern FORTRAN Language Programs – CSC 280 is a course from Department of Computer Science, Faculty of Science in the University of Port Harcourt as well as other Universities. It is offered as borrowed course by other departments to enable them have the knowledge of programming. Though, it was introduced to the University as GES 101 – Computer Appreciation and Application.
In this course, ForTran – Formula Translator language is obeyed. Students are expected to run the programmes using Plato FORTRAN Application.
The objective of the course is that, students will learn how to run programmes on their own before semester ends. Thus, the initiation of the course in the University.
To pass this course is very easy as you are very lucky to come across this article. You must fill your manual or workbook very well. You can use download the PDF of the ones we have filled to fill yours. Also, you are required to do well in your Test then your exams.
Contents
Few Programs you may be asked to run as test or exams
You may be asked to run program to calculate:
- Area of a Circle
- Velocity
- Simple Interest
- Number of students in your class
- Average of any five numbers
- Minimum of three integer numbers
- Factorial of any given number
Samples of Programs or Algorithms for some FORTRAN programs
Write a program to calculate the average of any five numbers?
Program Average5
Real :: a, b, c, d, e
Real :: sum
Real :: avg
Write (*’*) ‘Enter the five numbers, Press the ENTER key after each number’
Read (*’*) a, b, c, d, e
Sum = a + b + c + d + e
Avg = sum/5
Write (*’*) ‘The average of the five numbers :’, avg
End Program Average5
Answers to CSC 280 Workbook – Computer Programming Part I
Lab 1: Hello World
Observations/Output
Observation: The name of the program is ‘Hello’. The keywords such as ‘program’, ‘implicit none’, ‘write’ and ‘End program’ coloured blue. The text to the right of the exclamation mark is a comment.
Output: Hello World
Lab 2: Swaps
Algorithm
- Declare all variables
- Read in a and b
- Swap values i.e. Temp = a, a = b, b = Temp
- Display result
Observations/Output
Observation: The name of the program is ‘Swap’. The aim of this program is to move the value in variable a to be and vice versa. This is achieved by declaring the variable to perform the swapping of values.
Output: If a = 5, b = 6. The output will be: 6 5
Lab 3: Area of a Circle
Algorithm
- Declare all variables. Constant Pie = 3.142
- Supply value to R
- Calculate the area (i.e. area = pie*R**)
- Display area
Observations/Output
Observation: The program calculate the area of a circle given the radius. A constant pie was declared to be a real constant.
Output: Given that R = 6.
The area of the circle write radius 6 is 113.112
Lab 4: Average of any five numbers
Algorithm
- Declare all variables
- Supply values to the 5 values
- Calculate the sum
- Calculate the average
- Display result
Observations/Output
Observation: The program calculates the sum and average of the five values supplied during the experiment.
Output: Let a = 1, b =3, c = 5, d = 7, e = 9.
The average of the five numbers = 5.00000
Lab 5: Area of Sector
Algorithm
- Declare all variables
- Supply values to radius and angle
- Calculate the area of a sector
- Display area
Observations/Output
Observation: The program calculates the area of a sector of a circle given the radius and the angle of the sector. The name of the program is AreaSector.
Output: Let radius = 4, angle = 60
Radius = 4.000000, Angle of Sector = 60.00000
Area of sector = 8.37866
Lab 6: Area of a triangle of sides a, b and c
Algorithm
- Declare all variables
- Supply values to variables a, b and c
- Calculate the value of P, where
- Calculate area. Area =
- Display area
Observations/Output
Observation: The program calculates the area of a triangle given the three sides (a, b and c)
Output: Let a = 4, b = 5, c = 6.
The area of the triangle with sides 4cm, 5cm and 6cm is 9.92157cm square
Lab 7: Vertical motion under gravity
Algorithm
- Declare all variables
- Read in t and u
- Calculate displacement i.e. s = u*t – (g*t**2) / 2
- Display the result
Observations/Output
Observation: The name of the program is vertical. It calculates the vertical motion under gravity.
Output: Let t = 2, u = 10.
Time = 2, Displacement = 0
Lab 8: Solve Quadratic Equation
Algorithm
- Declare all variables
- Enter the value of a, b, c
- Display value of a, b and c
- Calculate the roots of the quadratic equation
- Display the roots
Observations/Output
Observation: The name of the program is QuadEqn1. The program calculates the roots of a quadratic equation given value of a, b and c.
Output: If a = 1, b = 5, c = 6.
Roots are – 2.000000 and – 3.000000
Lab 9: Sum values
Algorithm
- Declare all variables
- Initial sum and i i.e. sum = 0, i = 1.
- Do while i is less than 15
If i is less than 5 then sum = sum+1
If i is less than 10 then sum = sum+2
If i is less than 15 then sum = sum+3
Increase i by 3. i.e. i= i+3
End do
- Display result. i.e. sum
Observations/Output
Observation: The name of the program is summvalues. In the program, if-control structure is used to test the value of i and execute any of them if statements in the program.
Output:
1
2
4
9
10
Lab 7: Vertical motion under gravity
Algorithm
- Declare all variables
- Read in t and u
- Calculate displacement i.e. s = u*t – (g*t**2) / 2
- Display the result
Observations/Output
Observation: The name of the program is vertical. It calculates the vertical motion under gravity.
Output: Let t = 2, u = 10.
Time = 2, Displacement = 0
Lab 10: Minimum of Three Integer numbers
Algorithm
- Declare all variables
- Enter the value of A, B, C
- If a < b and a < c then a is minimum
Else
If b < a and b < c then b is minimum
Else
C is minimum
- Display the minimum of the numbers
Observations/Output
Observation: The program compares three numbers to three numbers to determine the minimum and display the result. The name of the program is Minimumval. In the program, IF… THEN… ELSE… END IF Construct was used, also, the logical operator ‘A’. was also, the logical operator to combine logical expression or condition.
Output: If a = 5, b = 10, c = 8.
The output will be:
The minimum of the three numbers is 5
Lab 11: Quadratic Equation
Algorithm
- Declare all variables
- Enter the values of A, B, C
- Compute the discriminant d
- If d is greater than zero, then find its square root
- Calculate the roots of the quadratic equation
Else
The roots are complex
- Display the discriminant, d
Observations/Output
Observation: The program calculates the roots of a quadratic equation given values of a, b and c. It also tests if the discriminant (d) of the equation to know it is greater than zero, so that the roots are real roots. Else the roots are complex roots and cannot be calculated.
Output: If a = 1, b = 5, c = 6.
Discriminant = 1.000000
Lab 12: Check Speed Fee
Algorithm
- Declare all variables
- Read in the value of speed
- If speed is less than or equal to 35, then fee = 0
Else if speed > 35 then fee = 2000
Else if speed > 50 then fee = 4000
Else fi speed > 65 then fee = 6000
- Display fee and speed
Observations/Output
Observation: The name of the program is checkSpeedFee. The program calculates speed fee given them in kilometers per hour.
Output: If Speed = 75Km/hr
The output will be:
Pay a fee of 6000 Naira for a Speed of 75 Km/hr.
If you need Part II of this workbook, kindly Click Here
To be updated on all Uniport Materials for Examination and Sure Questions
Subscribe to this site using your Email address for FREE
LIKE our Facebook page for updates
FOLLOW our Twitter Handle for udpates