Homepage Show
Accessibility links
BBC Account Notifications
More menu Search Bitesize Search Bitesize
BITESIZE
GCSE Eduqas Data structures and data typesVariables, constants and arrays form the basis for how data is stored within a program. They must be declared with meaningful identifier names and appropriate data types that match the data. Without the correct data structures and data types, programs will not work. Part of Computer Science Computational thinking and programming
quiz Test
Variables and constantsPrograms usually use data in some shape or form. Data in programs is usually referred to as values. VariablesA variable is a named memory location that holds a value. The value held in a variable can - and usually does - change as the program is running. Variables make it easy for a programmer to use memory locations. The computer keeps track of which memory location the variable refers to. All the programmer has to do is remember the name of the identifier the variable was given. Declaration and assignmentMost programming languages require a variable to be identified before a value is assigned to it. This is known as declaring a variable: score is integer This would declare a variable called Giving a variable a value is known as assignment. A variable must be assigned a value before it can be used. For example: set score = 0 This would assign the value 0 to the variable Some programming languages, such as Python, enable variables to be declared and assigned a value in the same line of code. ConstantsA constant allows a value to be assigned an identifier name. Unlike a variable, the value assigned to a constant cannot be changed whilst the program is running. Constants are useful because they are declared and assigned once, but can be referred to over and over again throughout the program. They are used for values that are unlikely to change, for example:
GCSE Subjects
Is named location in memory that is used to hold the value that may be modified by the program?Answer: A variable is a named memory location that temporarily stores data that can change while the program is running.
What is a named location in the memory?A variable is a named memory location which temporarily stores data that can change while the program is running.
Is a named location in the memory that is used to hold the value?A buffer is a named location in the memory which stores data temporarily. A buffer is a memory location that is used to store data for a short period of time. It is used so that data can be retrieved much quicker and there is no delay when the data is being retrieved by the processor.
What are named memory locations where values can be stored during the life of a program?A variable can be thought of as a memory location that can hold values of a specific type. The value in a variable may change during the life of the program—hence the name “variable.”
|