---
title: "Unconditional and computed GOTO"
subject: "Computer Programming"
chapter: 11
key: "semester_1/computer_programming:fortran-goto-compare"
source: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-goto-compare
site: BCT Engineering
---

# Unconditional and computed GOTO

Computer Programming · Chapter 11: Programming Language: FORTRAN

- Asked in: 2073 Chaitra, 3 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/fortran-goto-compare
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-11

## Question

Compare unconditional goto and computed goto in FORTRAN with syntax.

## Short answer

Unconditional GO TO (GO TO label) always transfers control to one label. Computed GO TO (GO TO (lab1, lab2, ...), expr) chooses a label based on an integer expression value (1 jumps to lab1, etc.), acting as a multi-way switch.

## Answer

**Unconditional GO TO** transfers control to one fixed labelled statement, always.

Syntax: `GO TO label`

```fortran
      GO TO 50
   ...
   50 PRINT *, 'JUMPED HERE'
```

**Computed GO TO** chooses one of several labels depending on the value of an integer expression.

Syntax: `GO TO (label1, label2, ..., labeln), integer_expression`

If the expression is 1, control goes to label1; if 2, to label2, and so on. If the value is less than 1 or greater than n, no jump is made and the next statement runs.

```fortran
      READ *, K
      GO TO (10, 20, 30), K
   10 PRINT *, 'ONE'
      STOP
   20 PRINT *, 'TWO'
      STOP
   30 PRINT *, 'THREE'
      END
```

| Basis | Unconditional GO TO | Computed GO TO |
|---|---|---|
| Destination | Single label | One of many labels |
| Condition | None | Value of an integer expression |
| Acts like | A simple jump | A multi-way switch |

## Check yourself

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

1. What does GO TO 50 do?
   A. Jumps to statement label 50 always
   B. Jumps to statement 50 only if K = 50
   C. Runs statement 50 five times
   D. Ends the program
   Answer: A. Unconditional GO TO transfers control to one fixed labelled statement with no condition. (Key point: Unconditional GO TO)

2. In GO TO (10, 20, 30), K with K = 2, where does control go?
   A. Label 10
   B. Label 20
   C. Label 30
   D. The next statement
   Answer: B. K selects the K-th label in the list, so K = 2 goes to label 20. (Key point: Computed GO TO)

3. What happens in a computed GO TO if K is 5 and only three labels are listed?
   A. The program stops with an error
   B. No jump is made and the next statement runs
   C. It jumps to the last label
   D. It jumps to label 5
   Answer: B. If the value is less than 1 or greater than n, no jump is made and the following statement executes. (Key point: Value out of range)

## Related in Computer Programming

- [Formatted I/O in FORTRAN with syntax](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-formatted-io-syntax) — Computer Programming, chapter 11
- [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
- [Two dimensional arrays in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-2d-array-syntax) — Computer Programming, chapter 11
