Education Tips

UNIPORT CSC 280: Answers to Introduction to Computer Programming (Modern FORTRAN) Practical Workbook Part I

Spread the love

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

  1. Declare all variables
  2. Read in a and b
  3. Swap values i.e. Temp = a, a = b, b = Temp
  4. 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

  1. Declare all variables. Constant Pie = 3.142
  2. Supply value to R
  3. Calculate the area (i.e. area = pie*R**)
  4. 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

  1. Declare all variables
  2. Supply values to the 5 values
  3. Calculate the sum
  4. Calculate the average
  5. 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

  1. Declare all variables
  2. Supply values to radius and angle
  3. Calculate the area of a sector
  4. 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

  1. Declare all variables
  2. Supply values to variables a, b and c
  3. Calculate the value of P, where
  4. Calculate area. Area =
  5. 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

  1. Declare all variables
  2. Read in t and u
  3. Calculate displacement i.e. s = u*t – (g*t**2) / 2
  4. 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

  1. Declare all variables
  2. Enter the value of a, b, c
  3. Display value of a, b and c
  4. Calculate the roots of the quadratic equation
  5. 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

  1. Declare all variables
  2. Initial sum and i i.e. sum = 0, i = 1.
  3. 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

  1. 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

  1. Declare all variables
  2. Read in t and u
  3. Calculate displacement i.e. s = u*t – (g*t**2) / 2
  4. 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

  1. Declare all variables
  2. Enter the value of A, B, C
  3. 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

  1. 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

  1. Declare all variables
  2. Enter the values of A, B, C
  3. Compute the discriminant d
  4. If d is greater than zero, then find its square root
  5. Calculate the roots of the quadratic equation

Else

The roots are complex

  1. 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

  1. Declare all variables
  2. Read in the value of speed
  3. 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

  1. 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

UNIPORT CSC 280: Answers to Introduction to Computer Programming (Modern FORTRAN) Practical Workbook Part I

basedonnews

Share
Published by
basedonnews

Recent Posts

NYSC Batch C Stream 2 2024 | Online Registration Starting Date, Mobilization and Camp Date

NYSC Batch C Stream 2 2024 Update | Online Registration Starting Date, Mobilization and Camp…

1 month ago

Nigerian Army (NA) 88RRI Recruitment 2024/2025 Application Form Portal

Nigerian Army (NA) 88RRI Recruitment 2024/2025 Application Form Portal - Do you want to apply…

1 month ago

Chief Security Officer (CSO) at United Nigeria Airlines: How to Apply

Chief Security Officer (CSO) at United Nigeria Airlines: How to Apply: United Nigeria Airlines is…

3 months ago

Safety and Quality Manager at United Nigeria Airlines – Apply Here

Safety and Quality Manager at United Nigeria Airlines - Apply Here:  I am directed to…

3 months ago

NYSC Corps Members Allowance – DG Gives Assurance of Stipend Hike

NYSC Corps Members Allowance - DG Gives Assurance of Stipend Hike This article is directed…

3 months ago

How To Check If Your FG Loan Application Status Is Verified

How To Check If Your FG Loan Application Status Is Verified: As the Federal Government…

3 months ago