EDUCATIONTECH

What Do Constants and Variables Mean in Computers?

0

Variable – Data Relationship

Computers use data called constants and variables throughout the process to solve problems . Data defined as “ constant ” are values ​​that never change during the solution process of the problem.

Constant values ​​can be numeric, characters or special symbols. In this case, this value is allocated a place in the computer’s memory and given a name. As long as the program is running, this value is called with the name given to it and its value can never be changed.

Variable – Data Relationship

Conversely, when a “variable” is defined, its value can change as long as the program runs (Figure 1.8). Variables are given names that express the values ​​they carry, in this way their defining features are formed.

Programmers should give a separate name to each variable needed in the solution process. So the computer uses this name to find the corresponding value in memory. The variable can be of different data types, but its name must be consistent with the value it contains.

For example, a variable named price may have a value of 50 assigned to it, this value may change as the program runs, but the name of the variable never changes.

Here are the rules to consider when naming and using variables:

  1. Give the variable names consistent with the value it contains.
  2. Do not use spaces when naming variables.
  3. When naming variables, start with a character.
  4. Be careful not to use mathematical symbols.

Below are the variable names used as “True” and “False”:

False True

1 number number1

School Number. school Number

Question? question

The following points should be noted about variable names.

  • The use of Turkish characters is not recommended because some platforms do not support it.
  • Command names used in programming languages ​​cannot be used as variables. The well-known ones; if, for, while, else, do, int, etc.
  • In variable naming, an underscore ( _ ) character can be used instead of a space character, but in variable naming, it usually starts with a lowercase letter and if a second word is to be written, it is followed by a capital letter immediately after the first word. This is called the use of “Camel Character”.

Example: tcIdNo

– Special characters cannot be used in variable names (like *,/, -,+, #,%,&,(,=,?,$,[,{…).

What are Data Types?

Previous article

You may also like

Comments

Leave a reply

Your email address will not be published. Required fields are marked *