Sample 2

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Sample 2 as PDF for free.

More details

  • Words: 268
  • Pages: 1
Declaration of variables In the simple program above there is no need to declare variables, although as your knowledge of the language increases you will see there is a need for this in most circumstances. If a value has not been assigned to a variable it is assumed that it contains its default value, a 0 if it is numeric or null if it is a string. You should spend time thinking about your variables and ensure that you choose an identifier, or name, that reflects the use to which the variable will be put. eg. dayofweek

or weeklypay

A more complicated example The final program in this section introduces a more advanced feature, the use of subroutines. Again, enter the program and run it to see what happens. PRINT"I will summon the butler procedure." summonbutler PRINT"Yes, bring up some tea and floppy discs..." END SUB summonbutler PRINT"you rang sir?" END SUB

This is a somewhat trivial program, but it introduces another feature of QuickBASIC, the SUBROUTINE. A subroutine is simply a little program within the main program that performs some function. In this case the subroutine simply prints You rang sir?

on the screen. Subroutines can be as complex as the main section of the program and can contain there own declarations and even their own subroutines. The main use of subroutines is to break down a program into smaller more manageable sections. They are particularly useful when you wish to perform the same function more than once as they can save a lot of typing. Subroutines and their uses will be described in more detail later.

Related Documents

Sample 2
May 2020 3
Sample 2
November 2019 7
Sample 2
May 2020 5
Sample 2
May 2020 5
Sample 2+2 Scf
May 2020 2
Published Sample 2
June 2020 1