What is a variable in programming language

Most times when we think about programming a computer we also think about variable. Variable is a very crucial aspect of computer programming and without variables our computer program will have no means of storing information in our computers. So let start by looking into what actually is a variable.
What is a  variable?
In a computer program a variable is use to store information that will be referenced and manipulated in our computer program to perform some reasonable tasks. They also provide a way of labeling data with a descriptive name, so our program can be easily understood by our  reader and  ourselves. It is likely correct to think of a variable as  a box that hold information. Their main purpose is to give a definite name to our data store in memory. This can then be used anywhere in our program.

Assigning a value to a variable.
Choosing a proper name for a variable is one of the most difficult tasks in  computer programming.  when you  name a variable, think deeply about the name. Try your possible best to make sure the name is very descriptive enough to portray the use of the variable in the program, so that other reader
can understand at a glance what the variable is meant for and even sometimes this can help you a lot to understand your  code when you revisit a code  you wrote after a long time.
When you  assign a variable, you use the  = (equal to) symbol to denote an  a value assignment. The name goes on the left and the value you want to store in the variable goes on the right.

int total_Score;
total_Score = 4;

Types of variables

Before we continue, you should be aware that there are five types of variables. Global variables, constant variables, instance variables, class variables, and local variables. While you should not worry too much about these topics in depth yet, here is a brief description of each.
Global variables are variable that can be visible for use  anywhere in our code and whose lifetime ends with the program source code it is declared in.
Constants are declared by capitalizing every letter in the variable's name. They are used for storing data that we are sure won't be change in our computer code. While most programming languages do not allow you to change the value assigned to a constant, Ruby  and C++ does. It will however throw a warning letting you know that there was a previous definition for that variable if you change the  value of the variable without casting out it constantness. Just because you can, doesn't mean you should change the value. In fact, you should not. Constants cannot be declared in method definitions, and are available throughout your application's scopes.
Example of a constant declaration:
Here will declare a variable of type int which means our variable is of an integer variable and then we assign an integer value of 4 to the variable total_Num_Player.

int total_Num_Player;
total_Num_Player = 4;

Comments