Calculator Programming Tutorial

Programming Building Blocks I

Control Flow I

Sequences

The first and simplest of the types of control flow is sequence: the following of one operation by another operation. In the factorial flowchart, the two boxes after the test (“a > n”) are a sequence:

These two steps are to be carried out in the order shown: otherwise, the product b, instead of becoming n × n-1 × n-2 × ... × 1, could be n × n × n-2 × n-2 × ... × 1. Generally, flowcharts use sequencing to indicate a mandatory order of computations, as in this case. However, sometimes separate boxes are used when they are not strictly necessary.

Programs, however, generally impose an evaluation order simply through the rules of the language. A program is linear text, and one statement must of necessity come before another statement. This sequencing might or might not be necessary. There are languages in which it is possible to write unsequenced statements, but these languages are rarely used.

In all of the calculator, Visual Basic for Applications, and JavaScript, sequencing is indicated by lexical order. When two statements appear without other intervening control structures, the one appearing first in the program is executed first.

Page last updated 30 December 2001.

Brian’s Casio Calculator Corner

Home

Programs

Tutorial

Preface

Introduction

Fundamentals

Building Blocks I

Introduction

Data Types

Numbers

Variables

Expressions

Control Flow I

Introduction

Sequences

Alternatives

Loops

Composition

Control Flow II

Subprograms

Basic I/O

Algorithms

A First Program

Examples

Exercises

Modularization

Data Structures I

Recursion

Program Attributes

Building Blocks II

Algorithm Analysis

Structuring

Data Structures II

Abstract Types

Objects

Problem Analysis

Reference Card

References

Puzzles

Site Information