Skip to main content

Activity 7

  • Chapter
  • 16 Accesses

Part of the book series: Basic Books in Electronics ((BBE))

Abstract

This activity is about a feature of BASIC which enables a series of related calculations to be performed in what is usually referred to as a loop. An example of a loop was used in activity 5.2 where a set of tables of squares, cubes and square roots were printed for a set number of numbers. The loops were generated by IF…THEN…and GO TO statements. A neater way of doing this is by using a FOR…NEXT…loop. Type in and run the program shown in activity 7.1. When you run the program you should see that the values of X which are printed are 0, 2, 4, 6, 8 and 10. This is the meaning of the statement in line 10 which says that the value of X must start at zero and go up to 10 in steps of 2. Line 40 defines the end of the loop and it is at this point that the value of X is tested for its terminal value, in this case 10, and the program returned to line 10 if the terminal value has not yet been reached. If the terminal value has been reached, then the program continues from line 50 and drops out of the loop.

This is a preview of subscription content, log in via an institution.

Author information

Authors and Affiliations

Authors

Copyright information

© 1981 P. E. Gosling

About this chapter

Cite this chapter

Gosling, P.E. (1981). Activity 7. In: Program Your Microcomputer in BASIC. Basic Books in Electronics. Palgrave, London. https://doi.org/10.1007/978-1-349-05389-6_11

Download citation

  • DOI: https://doi.org/10.1007/978-1-349-05389-6_11

  • Publisher Name: Palgrave, London

  • Print ISBN: 978-1-349-05391-9

  • Online ISBN: 978-1-349-05389-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics