What are named memory locations where values can be stored during the life of a program?

Homepage

  • Skip to content
  • Accessibility Help

BBC Account

Notifications

  • Home
  • News
  • Sport
  • Weather
  • iPlayer
  • Sounds
  • Bitesize
  • CBeebies
  • CBBC
  • Food
  • Home
  • News
  • Sport
  • Reel
  • Worklife
  • Travel
  • Future
  • Culture
  • TV
  • Weather
  • Sounds

More menu

Search Bitesize Search Bitesize

  • Home
  • News
  • Sport
  • Weather
  • iPlayer
  • Sounds
  • Bitesize
  • CBeebies
  • CBBC
  • Food
  • Home
  • News
  • Sport
  • Reel
  • Worklife
  • Travel
  • Future
  • Culture
  • TV
  • Weather
  • Sounds
Close menu

BITESIZE

  • Home
  • Learn
  • Support
  • Careers
    • My Bitesize

GCSE

Eduqas

Data structures and data types

Variables, 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

  • Revise

  • quiz

    Test

  1. previous

  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. 6
  8. 7
  9. 8
  10. Page4of 8
  11. next

Variables and constants

Programs usually use data in some shape or form. Data in programs is usually referred to as values.

Variables

A 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 assignment

Most 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 score that would hold integers.

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 score.

Some programming languages, such as Python, enable variables to be declared and assigned a value in the same line of code.

Constants

A 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:

  • pi, eg constant PI = 3.142

  1. previous

  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. 6
  8. 7
  9. 8
  10. Page4of 8
  11. next

GCSE Subjects

  1. Art and Design
  2. Biology (Single Science)
  3. Business
  4. Chemistry (Single Science)
  5. Combined Science
  6. Computer Science
  7. Design and Technology
  8. Digital Technology (CCEA)
  9. Drama
  10. English Language
  11. English Literature
  12. French
  13. Geography
  14. German
  15. History
  16. Home Economics: Food and Nutrition (CCEA)
  17. Hospitality (CCEA)
  18. ICT
  19. Irish – Learners (CCEA)
  20. Journalism (CCEA)
  21. Learning for Life and Work (CCEA)
  22. Mandarin
  23. Maths
  24. Maths Numeracy (WJEC)
  25. Media Studies
  26. Modern Foreign Languages
  27. Moving Image Arts (CCEA)
  28. Music
  29. Physical Education
  30. Physics (Single Science)
  31. PSHE and Citizenship
  32. Religious Studies
  33. Science
  34. Sociology
  35. Spanish
  36. Welsh Second Language (WJEC)

What are the memory locations are available to store the values?

Variables are usually stored in RAM. This is either on the heap (e.g. all global variables will usually go there) or on the stack (all variables declared within a method/function usually go there). Stack and Heap are both RAM, just different locations. Pointers have different rules.

What refers to named memory locations of the program?

Identifiers are descriptive names that are mapped to locations in the computer's memory. Once a memory location is given a specific name, we can refer to that location using the identifier rather than the numeric address.

What is used by value types to store value in memory locations?

Variables are nothing but reserved memory locations to store values.

Which part of a script is a named memory location which stores data of a specific type?

A variable is a named storage location in the computer's memory that contains data, such as a number or a text string. The data contained in a variable is called the variable's value. Variables give you a way to store, retrieve, and manipulate values using names that help you understand what the script does.