Variables and Constants in Programming Languages.

       Variables and Constants

We all would be a little bit familiar with the variables and constants in mathematics. If not then also it's OK, we  are all humans and we all can learn anything at any point of time. Variables and constants are very much similar to those used in Algebra stream of Mathematics. We will discuss both variables and constants both of them one by one.

An Algebric Expression


Constants;-


Constants are mainly those quantities whose value cannot be modified or changed. They can be in any form integer, decimal, hexadecimal, floating point no., characters etc., but they are mainly in two common forms in INTEGERS and ALPHABETS ( CHARACTERS ). You can understand constant very much by the following example-
We will assign x the value 3
                                                             
                                                                             x=3 

we have got this expression. This expression does nothing except assigning the constant value 3 to x the variable, here constant 3 cannot be changed on its own or you can say 3 cannot be updated to 4 on it's own, 3 has it's own identity, hence it cannot be changed.



Variables;-


Variables are mainly represented by alphabets of English grammar such as x, y, z etc. The main thing which differentiates them from constants is that they don't have a fixed value. They contain that value which we assign to them. it can be in the form of an expression or it can simply be a numeric value (a constant). They don't have any identity of their own, they are provided an identity by assigning a value to them. You can say that Assigning a value means giving some value to the variable.
                                                                           x=3,
                                                                          x=3y
Here we have got 2 equations, x=3 and x=3y,

1. In first expression we are assigning an integer value to the expression.
2. In second expression we have assigned an equation to the variable and value of x is changing with respect to x.



Conclusion:- 


We were able to provide you with a basic knowledge of "What are Variables and Constants?". Please tell us how you feel about this article in the comment section. We would love to hear from you.

Comments