The importance of variables in programming languages

If you´ve decided to take on private lessons in programming, you may have already learned that every programming language used involves the concept of a variable.

Find your perfect tutor

What is a variable?

A variable is the name given to a computer memory location where some data is stored for processing. There are some programming languages in which we need to define a variable before we use it and there are some programming languages in which we don't need to define a variable. No matter what is the case, whenever there is a variable then there are some aspects associated with it.

What types of variables are there?

When we use a variable, then we deal with following aspects of variable:

  • name
  • address
  • value
  • data type
  • size

So every variable has a name. In programming langauges like C, C++ and Java we need to define them. When we define them then we need to mention their data type such as char, int, float.

What are data types?

The data type of variables basically define the type of values that the variable can contain. For example we can define variables like below:

  • Char = characters (e.g char ch)
  • Int = integers (e.g int age)
  • Float = floating point (e.g float price)

Once a variable is defined then we can put some value in it like below:

  • ch='A';
  • age=20;
  • price=50.5;

Do we define variables in all programming languages?

There are some programming languages where we don't need to define a variable like Python, PHP, JavaScript. In these languages when we need to store some value then we have to define a variable like below:

  • marks=50;
  • rate=100.5;

Once some value is stored in a variable then we can display its value using some output statement. We can perform mathematical operations using mathmatical operators. We can write conditions using relational operators. So variables are the most valuable part of a program.

If you´re interested in learning programming and you´d like private lessons, I am a freelance software developer and private programming tutor. Feel free to get in contact about an initial lesson!

 

Did you like this article? Share it now
Pankaj Kumar
I am working as a freelance software developer since 2004. I can develop web apps as well as mobile apps. I am also teaching online programming languages to various students.Contact
Teaches Computer science classes
Contact
Use our Smart Finder