0% found this document useful (0 votes)
113 views

Variables

Variables are used to store values during program execution and come in several data types including integers, floats, strings, Booleans, and more. Arrays allow storing groups of like variables, such as storing names of 20 pupils in a string array. There are two types of variables: global variables that can be accessed throughout a program and should be declared at the start, and local variables used within a single subprocedure that don't affect other variables with the same name.

Uploaded by

Vishal Paupiah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

Variables

Variables are used to store values during program execution and come in several data types including integers, floats, strings, Booleans, and more. Arrays allow storing groups of like variables, such as storing names of 20 pupils in a string array. There are two types of variables: global variables that can be accessed throughout a program and should be declared at the start, and local variables used within a single subprocedure that don't affect other variables with the same name.

Uploaded by

Vishal Paupiah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Variables

Variables are used to store values during the execution of a program.


Data Types
Integer used to store positive or negative whole numbers uses 2 bytes to store the
number.
Single (often called real) used to store decimals - 4 bytes floating point number.
String used to store alphanumeric (text and numbers) characters.
Boolean stores either the value TRUE or FALSE.
Long stores a 4-byte integer.
Double stores an 8-byte floating-point number
Arrays are used to store a group of like variables. For example:
To store the names of 20 pupils in class you would use an array of 20 strings.
To store a list of five test marks for a pupil you would use an array of 5 integers.
Exercise1



There are two types of variables
1. Global Variable
Global variables can be accessed throughout the program and should be declared at the
beginning of the program code.

2. Local Variable
Local variables are used within a single sub procedure or function of a program. It is good
practice to use local variables whenever possible.

You could have two local variables in different sub procedures in a program with the
same name and they would not affect each other.

You might also like