---
title: "FORTRAN characteristics; compute π"
subject: "Computer Programming"
chapter: 11
key: "semester_1/computer_programming:fortran-characteristics-pi"
source: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-characteristics-pi
site: BCT Engineering
---

# FORTRAN characteristics; compute π

Computer Programming · Chapter 11: Programming Language: FORTRAN

- Asked in: 2074 Asoj, 8 marks
- Video: [Write a Fortran program which will determine the value of "PI"](https://www.youtube.com/watch?v=m5yWTZSole8) — FORTRAN90
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-characteristics-pi
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-11

## Question

What are the characteristics of FORTRAN Programming? Write a program in FORTRAN to calculate the value of π by evaluating the following formula for the first 25 terms.
π = 4(1 - 1/3 + 1/5 - 1/7 + 1/9 - …)

## Short answer

FORTRAN is a high-level compiled language for scientific computing, with strong numerical support, array handling, intrinsic functions, formatted I/O, and modularity. Program to compute pi: sum the series 4(1 - 1/3 + 1/5 - 1/7 + ...) for 25 terms using a DO loop with term (-1)^(k+1)/(2k-1). The computed value is approximately 3.181577.

## Answer

#### Characteristics of FORTRAN
1. The name comes from **FOR**mula **TRAN**slation; it was the first widely used high-level language (IBM, 1957).
2. It is designed for **scientific and engineering** calculation, with strong numerical and mathematical support (real, double precision and complex types).
3. It is a **compiled** language, so programs run fast.
4. The syntax is simple and close to mathematical formulas (`A = B*C + D`).
5. It has good **array handling** and many built-in (intrinsic) functions.
6. It supports modular programming with **functions and subroutines**, and has formatted input/output.
7. FORTRAN 77 uses a fixed-form layout (columns 1–72); later versions (90 and above) have free form, modules and pointers.
8. It is standardised and portable, and has a large library of tested scientific code.

#### Program: π by the series π = 4 (1 − 1/3 + 1/5 − 1/7 + …) for 25 terms
The K-th term is (−1)^(K+1) / (2K − 1). `(-1.0)**(K+1)` gives the alternating sign.

```fortran
      PROGRAM PIVAL
      REAL S, PI
      INTEGER K
      S = 0.0
      DO 10 K = 1, 25
         S = S + (-1.0)**(K+1) / (2.0*K - 1.0)
   10 CONTINUE
      PI = 4.0 * S
      WRITE(*,20) PI
   20 FORMAT(' PI = ', F10.6)
      STOP
      END
```

**Result:** with 25 terms the program gives about **3.181577** (calculated separately). The series converges slowly, so 25 terms give only one correct decimal place; the true value is 3.141593.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does the name FORTRAN come from?
   A. FORmula TRANslation
   B. FORward TRANsfer
   C. FORmat TRANsform
   D. FOR TRAINing
   Answer: A. FORTRAN stands for FORmula TRANslation and was designed for scientific and engineering calculation. (Key point: Name of FORTRAN)

2. Why do FORTRAN programs run fast?
   A. They are interpreted line by line
   B. They are compiled
   C. They have no loops
   D. They use only integers
   Answer: B. FORTRAN is a compiled language, so the program is translated to machine code before running. (Key point: Compiled language)

3. What is the K-th term of the series 1 - 1/3 + 1/5 - ... ?
   A. (-1)^K / (2K)
   B. (-1)^(K+1) / (2K - 1)
   C. 1 / (K + 2)
   D. (-1)^(K-1) / (K+1)
   Answer: B. Odd denominators 2K-1 with signs +, -, +, ... are given by (-1)^(K+1). (Key point: K-th term)

4. After 25 terms, how close is the computed value to the true pi?
   A. Exact to 6 decimals
   B. Only about 1 correct decimal because the series converges slowly
   C. Exactly 3.0
   D. Exactly 4.0
   Answer: B. The series converges very slowly; the 25-term sum gives about 3.18, while pi = 3.141593. (Key point: Accuracy)

## Related in Computer Programming

- [Structure of a FORTRAN program](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-structure) — Computer Programming, chapter 11, asked 5×
- [Computer program and programming](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adefine-program-programming) — Computer Programming, chapter 2
- [Quadratic equation roots in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-quadratic-roots) — Computer Programming, chapter 11, asked 2×
- [GOTO types; sum of series program](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-goto-types-series) — Computer Programming, chapter 11
- [Sort array ascending in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-sort-ascending) — Computer Programming, chapter 11, asked 2×
- [Largest of n numbers in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-largest-n-numbers) — Computer Programming, chapter 11

## Related in other subjects

- [Program for RK-4 first order IVP](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark4-program-first-order) — Numerical Method, chapter 6
- [Calorific value of fuel by Dulong's formula](https://www.bctengineer.com/question.md?key=semester_6%2Finternal_combustion_engines%3Acalorific-value-dulong-formula-numerical) — Internal Combustion Engines, chapter 3
- [First four terms of Taylor series about z = 2](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Ataylor-series-z-plus-1-about-2) — Applied Mathematics, chapter 1
- [Direct programming of a first-order filter](https://www.bctengineer.com/question.md?key=semester_6%2Fdigital_control_system%3Adirect-programming-first-order) — Digital Control System, chapter 4
