Variables vs. Consonants – Programming Fundamentals

Last updated on July 15th, 2023 at 03:53 pm

Grammarly Writing Support

This article on programming fundamentals seeks to introduce the idea of variables and consonants. We explain what these concepts mean and when to use each in a computer program.

Variables and consonants contain values that are used in calculations. However, each of these has a different use, and understanding this will help us to know when it is suitable to use one or the other.

Are you new to programming? Programming is creating the solution to a problem. However there are many other stages in the problem solving process that comes before we write our computer program. Visit our article on what an algorithm is and the flowchart algorithm to learn more.

What is a consonant?

A consonant is a value that cannot be changed while the program is being executed. It contains a set value for the duration.

What is a variable?

Like a consonant, a variable holds a value. However, while the program is running, the value of a variable may be changed several times by a change in assignment, calculation, as a counter, or by other means.

Note that the very word variable means that it is changeable.

Variables vs. consonants – Programming fundamentals

Before you choose whether to use a variable or consonant in your program, you need first to understand what the value is being used for and whether it will change during the program execution. If it will, then you need to declare the value as a variable and not a consonant. On the other hand, if the value will remain the same throughout the execution of the program, you should declare it as a consonant.

Types of Data – Programming fundamentals

There are several data types in both mathematics and information technology. These data types indicate to the computer what type of information will be entered and how much space to allocate for that value, and it also restricts the manner in which the information may be used or manipulated.

Some types of data used in programming are:

  • String: Eg. Names;
  • Integer numbers: 01234;
  • Real or floating point numbers: 1.789;
  • Boolean value: True or false; or
  • Character: c, d, e.

When writing a computer program, it is important to test your algorithm for correctness. For this, we use a trace table. To learn more about trace tables, visit our article on what a trace table is and how to prepare one.

Before you go

We do our best to be as thorough as possible in the information we provide. However, if you have any questions or comments, be sure to leave them in the section below, and we will get back to you.