---
title: "COBOL: 3 Alternatives Where You Can Avoid GO TO Statements"
description: "GO TO statement really not required in COBOL. You can avoid using alternative methods. Read more to improve performance of your program."
url: https://srinimf.com/2019/01/20/3-go-to-statements-to-avoid-in-cobol/
date: 2019-01-20
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2019/01/cobol-go-to-statements-1.jpg?fit=1200%2C700&ssl=1
categories: ["COBOL"]
tags: ["COBOL Tips and Tricks", "GO TO in COBOL", "How to avoid goto in COBOL"]
type: post
lang: en
---

# COBOL: 3 Alternatives Where You Can Avoid GO TO Statements

GO TO statements kill your application performance. It is not a part of the structural design. Avoid [these mistakes](https://srinimf.com/2012/02/22/dont-make-these-mistakes-at-your-new-job/) in your program.

## GO TO Statement

GO TO statement will not give control back. It just drops control at destiny. When you compare GOTO with Perform, then Perform is a much better option.

**GO TO is first introduced in FORTRAN language in 1957.**

![](https://i0.wp.com/srinimf.com/wp-content/uploads/2019/01/goto.png?resize=701%2C74&ssl=1)

**The primary criticism is that code that uses goto statements is harder to understand than alternative constructions.**

You can tell in interview, if we avoid GO TO statements, you can improve performance.

## Alternative: 1

Sample COBOL Program.

Related[COBOL: Static Vs Dynamic Call Which is Better](https://srinimf.com/2015/01/25/cobol-static-call-and-dynamic-call/)

```
2020-TEST-SECTION  SECTION.
Move A To B. 
IF B > 50
GO TO 2020-EXIT 
END-IF. 
EXIT-2020. 
EXIT.
```

[How to](https://srinimf.com/2016/08/24/how-to-use-perform-test-after-logic-in-cobol/) re-write the Code.

```
2020-TEST-SECTION  SECTION.
Move A To B. 
IF B > 50
CONTINUE 
END-IF. 
EXIT-2020. 
EXIT.
```

Related[CONTINUE vs SECTION in COBOL not the same why](https://srinimf.com/2017/07/24/the-clear-idea-on-continue-and-section-in-cobol/)

In the above example CONTINUE helps you to come out of your section.

## Alternative: 2

```
2021-TEST-SECTION SECTION.
Move A To B. IF B > 50
GO TO 2021-EXIT
END-IF. 
Move B To C. 
IF C > 50
GO TO 2021-EXIT 
END-IF. 
EXIT-2021. 
EXIT.
```

[How to](https://srinimf.com/2015/10/13/file-open-should-be-input-or-i-o-in-cobol-start-statement/) Avoid GO TO Statement.

```
2021-TEST-SECTION SECTION.
Move A To B. IF B > 50
SET B IS TRUE
END-IF.
Move B To C.
IF C > 50
SET C IS TRUE
END-IF.
EXIT-2021.
EXIT.
*** Your Next Logic would be
IF B
PERFORM 2022-B-SECTION.
END-IF.
IF C
PERFORM
2023-C-SECTION.
END-IF.
```

Section and Paragraph both are different. The word SECTION you need to write in the first line of the section. No need to write anything for paragraphs. A section can contain paragraphs.

## Alternative: 3

```
2023-TEST-SECTION SECTION.
Move A To B.
IF B > 50
GO TO 2024-TEST-SECTION
END-IF.
EXIT-2023.
EXIT.
```

The above way of using GO TO is a crude method. Instead, you can use code as below. The EXIT is the last statement in a section or Paragraph.

```
PERFORM 2023-TEST-SECTION
PERFORM 2024-TEST-SECTION
*** Sections start here.
2023-TEST-SECTION SECTION.
Move A To B. IF B > 50
CONTINUE 
END-IF. 
EXIT-2023.
EXIT.
```

Related Posts

- [COBOL: How to Write Clean Programs](https://srinimf.com/2015/12/03/10-superb-ways-to-write-your-cobol-program/)DateDecember 3, 2015
- [The Purpose of ‘When Other’ in COBOL EVALUATE](https://srinimf.com/2016/09/24/how-to-control-cobol-evaluate-logic/)DateSeptember 24, 2016
- [EXIT PROGRAM – Real Reason to Code in Cobol Subroutine](https://srinimf.com/2015/10/04/cobol-subroutine-why-exit-program-is-mandatory/)DateOctober 4, 2015

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2019%2F01%2F20%2F3-go-to-statements-to-avoid-in-cobol%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fcobol-go-to-statements-1.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=COBOL%3A%203%20Alternatives%20Where%20You%20Can%20Avoid%20GO%20TO%20Statements)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2019/01/20/3-go-to-statements-to-avoid-in-cobol/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2019/01/20/3-go-to-statements-to-avoid-in-cobol/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2019/01/20/3-go-to-statements-to-avoid-in-cobol/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2019/01/20/3-go-to-statements-to-avoid-in-cobol/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%3A%203%20Alternatives%20Where%20You%20Can%20Avoid%20GO%20TO%20Statements&body=https%3A%2F%2Fsrinimf.com%2F2019%2F01%2F20%2F3-go-to-statements-to-avoid-in-cobol%2F&share=email)
-

### Like this:

Like Loading…
