0% found this document useful (0 votes)
5 views16 pages

ForTran Programming Tasks and Solutions

The document outlines a ForTran program containing various functionalities, including temperature conversion, geometric calculations, salary computation, and matrix operations. Each program is briefly described with its input and output requirements. The document serves as a comprehensive guide for implementing these programs in ForTran.

Uploaded by

u2303044
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

ForTran Programming Tasks and Solutions

The document outlines a ForTran program containing various functionalities, including temperature conversion, geometric calculations, salary computation, and matrix operations. Each program is briefly described with its input and output requirements. The document serves as a comprehensive guide for implementing these programs in ForTran.

Uploaded by

u2303044
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ForTran Program | A.H.

Riaz - 2103060

ForTran Program
1) A program for converting temperature from Fahrenheit to Centigrade ......................................................... 2
2) A program for calculating Perimeter & Area of a Triangle. ............................................................................. 2
3) A program that inputs the radius of a circle & outputs – ................................................................................ 3
(a) Area of the circle ...................................................................................................................................... 3
(b) The area of the largest square contained within the circle ..................................................................... 3
(c) The ratio of that of (a) to (b) .................................................................................................................... 3
4) A program that reads a four-digit number & finds the sum of individual digits. ............................................ 3
5) A program that accepts three names each a maximum of 20 characters & produces the following output: 4
(a) A single character string of length 3 made up of the 1st letters of the three names ................... 4
(b) A line of output on which appear three-character strings, each of them made of the 14th, 15th,
th th
16 , 17 letters of the three names................................................................................................... 4
(c) A single string of length 20 such that it contains the 1st seven characters of the first name,
characters 8 through 14 of the 2nd name, & characters 14 through 20 of the 3rd name.................... 4
6) A program to compute the gross salary & net pay for the employee, assuming the tax deduction to be at
the rate of 10% of the employee’s gross salary, if it is less then tk 1000, & at the rate of 20% otherwise.
The input should be the number of hours worked & the hourly wage rate.................................................... 5
7) A program to find the largest of the three numbers ....................................................................................... 6
8) A program that can calculate a quadratic equation ........................................................................................ 7
9) A program that reads 3 positive numbers & determines – ............................................................................. 8
(a) whether they form a triangle? ................................................................................................................. 8
(b) if yes, then determine whether the triangle will be obtuse or right or acute angle triangle ........ 8
(c) if it is acute, then determine whether the triangle will be equilateral or isosceles or a scalene
triangle .......................................................................................................................................................... 8
10) A program that reads out a number & prints out the sum of its digit ............................................................. 9
11) A program that prints the sum of the followings: ......................................................................................... 10
12) A program to compute N! .............................................................................................................................. 11
13) A program to determine if a number is prime or not. ................................................................................... 11
14) Three positive integers a, b, c, where a < b < c, form a Pythagorean triplet if a² + b² = c². ........................... 12
Write a program that generates all Pythagorean triplets a, b, c, where a, b ≤ 25 ...................................... 12
15) Input of 3×2 matrix element & show it on screen in Matrix form ................................................................. 13
16) Addition of two 2×3 Matrices ........................................................................................................................ 14
17) Transpose of a 2×3 Matrices .......................................................................................................................... 15
18) Multiplication of (2×3) & (3×4) Matrices ....................................................................................................... 16

P a g e 1 | 16
ForTran Program | A.H. Riaz - 2103060

06.01
A program for converting temperature from Fahrenheit to Centigrade
INPUT
OUTPUT
06.04

A program for calculating Perimeter & Area of a Triangle.


INPUT
OUTPUT

P a g e 2 | 16
ForTran Program | A.H. Riaz - 2103060

A program that inputs the radius of a circle & outputs –


06.05
(a) Area of the circle
(b) The area of the largest square contained within the circle
(c) The ratio of that of (a) to (b)
INPUT
OUTPUT

A program that reads a four-digit number & finds the sum of


06.06
individual digits.
INPUT

OUTPUT

P a g e 3 | 16
ForTran Program | A.H. Riaz - 2103060

A program that accepts three names each a maximum of 20 characters


& produces the following output:
(a) A single character string of length 3 made up of the 1st
letters of the three names
06.07

(b) A line of output on which appear three-character strings,


each of them made of the 14th, 15th, 16th, 17th letters
of the three names
(c) A single string of length 20 such that it contains the
1st seven characters of the first name, characters 8 through
14 of the 2nd name, & characters 14 through 20 of the 3rd name
INPUT
OUTPUT

P a g e 4 | 16
ForTran Program | A.H. Riaz - 2103060

07.01 A program to compute the gross salary & net pay for the employee,
assuming the tax deduction to be at the rate of 10% of the employee’s
gross salary, if it is less then tk 1000, & at the rate of 20% otherwise. The
input should be the number of hours worked & the hourly wage rate.
INPUT
OUTPUT

P a g e 5 | 16
ForTran Program | A.H. Riaz - 2103060

07.02
A program to find the largest of the three numbers
INPUT
OUTPUT

P a g e 6 | 16
ForTran Program | A.H. Riaz - 2103060

07.04
INPUT
OUTPUT A program that can calculate a quadratic equation

P a g e 7 | 16
ForTran Program | A.H. Riaz - 2103060

A program that reads 3 positive numbers & determines –


(a) whether they form a triangle?
07.05

(b) if yes, then determine whether the triangle will be obtuse or right
or acute angle triangle
(c) if it is acute, then determine whether the triangle will be
equilateral or isosceles or a scalene triangle
INPUT
OUTPUT

P a g e 8 | 16
ForTran Program | A.H. Riaz - 2103060

08.02
A program that reads out a number & prints out the sum of its digit

• MOD is a function to calculate the remainder


• MOD (X,Y) = X ‒ ((X / Y)*Y)
Basic

• MOD (5,2) = 5 ‒ ((5 / 2)*2) = 1


• MOD (563,10) = 563 ‒ ((563 / 10)*10) = 3
INPUT
OUTPUT

P a g e 9 | 16
ForTran Program | A.H. Riaz - 2103060

A program that prints the sum of the followings:


1 + 2 + 3 + 4 + ⋯⋯⋯+ 𝑁
06.06

12 + 22 + 32 + 42 + ⋯ ⋯ ⋯ + 𝑁 2
13 + 23 + 33 + 43 + ⋯ ⋯ ⋯ + 𝑁 3
2 + 4 + 6 + 8 + ⋯ ⋯ ⋯ + 2𝑁
1 + 3 + 5 + 7 + ⋯ ⋯ ⋯ + (2𝑁 − 1)
INPUT
OUTPUT

P a g e 10 | 16
ForTran Program | A.H. Riaz - 2103060

08.03 A program to compute N!

INPUT

OUTPUT

08.04 A program to determine if a number is prime or not.

INPUT

OUTPUT

P a g e 11 | 16
ForTran Program | A.H. Riaz - 2103060

08.05 Three positive integers a, b, c, where a < b < c,


form a Pythagorean triplet if a² + b² = c².
Write a program that generates all Pythagorean triplets a, b, c,
where a, b ≤ 25
• The integer solutions to the Pythagorean Theorem, a2 + b2 = c2 are
called Pythagorean Triples.
• Pythagorean Triplets list:
Basic
INPUT
OUTPUT

P a g e 12 | 16
ForTran Program | A.H. Riaz - 2103060

09
Input of 3×2 matrix element & show it on screen in Matrix form
INPUT
OUTPUT

P a g e 13 | 16
ForTran Program | A.H. Riaz - 2103060

09
Addition of two 2×3 Matrices
INPUT
OUTPUT

P a g e 14 | 16
ForTran Program | A.H. Riaz - 2103060

09
Transpose of a 2×3 Matrices
INPUT
OUTPUT

P a g e 15 | 16
ForTran Program | A.H. Riaz - 2103060

09.05 Multiplication of (2×3) & (3×4) Matrices


INPUT
OUTPUT

P a g e 16 | 16

You might also like