Skip to main content

Programming Variables

 A variable is an element of a Computer Program. Computers Programs are stored in Computer memory. Computer memory is also the seat of Program variables. Variables stored in Computer memory can be identified. The name given to the variable is the identifier of the variable. This identifier helps to identify the variable.

A Program variable is very much useful. Computer Programmers use variables meaningfully and purposefully. Variables dish out data to Program instructions. Instructions of a Computer Program are able to use variables quite effectively. 

A value that is acquired by a Program variable is used by Program instruction. Whenever a variable is encountered by a Program instruction, a simple substitution occurs. The variable is substituted by the value. This is how processing of data is helped.

Let us see how we have to play with variables used in a Computer Program:

______________________________________

Integer x, y

x = 4

y = 5

______________________________________

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

//x and y are variables 

//These variables can acquire values

//The acquired values are integers

//Only integers can be acquired 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

The variable is substituted by a value that has earlier been acquired. We can easily recall that the variable has been given a certain value. 

It is important to note that a variable that dangles ( simply hangs ) is not usable. Unless and until a value is properly acquired by a variable, use of the variable is a serious mistake. Yes, it's a mistake on the part of a Programmer to use a variable that has nothing inside ( no value).  

____________________________________

Integer p, q, r;

p = 9;

r = p + q //Error!

____________________________________


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Note: Use of 'p' is fine, but still no value has been acquired by 'q'. 'q' simply hangs and its state is somewhat undefined. So, we have to correct ourselves from using a variable lying in an undefined state.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


_____________________________________

Note: Many times beginners use a variable that is not associated with a proper value.

______________________________________

We have to always keep in mind that a variable can acquire only a proper value. So, a Computer Programmer has to be very alert in this respect. 

It is emphasised that only a proper value that is in tune is acquired by a Program variable. An attuned value is approved by a Computer. So, those new to the Programming world have to be very careful. They are specially recommended to  note this piece of advice.

____________________________

____________________________

Goodbye! 

Have a great day!!

___________________________

___________________________



Comments

Popular posts from this blog

Interface Message Processor ( IMP )

Interface Message Processor ( IMP ) is a special purpose Computer. The Processor plays a vital role in Host-to-Host communication. IMP is placed between Host Computers.  IMP helps Hosts to exchange information. IMPs ( Interface Message Processors ) form a group. The group dedicates itself towards reliable transmission of Packets. _________________________ Note: An Interface Message Processor can be supposed to have a face. Firstly this supposed face of IMP is in the direction of the first Host, which sends the  message. Secondly, this face is turned towards the other Host.  Now, the IMP,  with its face turned around, communicates with this other Host.  Transformed message from IMP is communicated to this Host. __________________________ Message ( a piece of information ) sent from the Host ( source of information  ) is transformed into Packets. Transformation of the message into Packets is performed by an IMP. These Packets are forwarded to the receiver H...

Understanding Distribution

Distributed presence means that more than one object is there. Also, these objects are situated at more than one location.  One object may establish communication with another object. The first object may deliver some message. The message can be received by another object. It can be said that object distribution is successful, as one object has succeeded in delivering a message. The second object has successfully received the message. Two objects are at a distance. Communication brings them closer. The successful communication has served to highlight that the idea of distribution is meaningful. Distribution helps exchange of information. Many different objects can form a group.  Two groups can occupy different locations.  It may happen that at a particular location there are several objects. But, all these objects talk among themselves.They talk among themselves and make things happen.  There is a resultant of this talk process. All the communicating objects  at...

Message Switching

Message is a piece of information. Switching means movement.  In a Network there are a number of nodes. Nodes are vital junctions of a Network. Message Switching means transmission from one node ( one point ) of a Network to another node ( another point ). So, transmission is from point to point. Transmission from one point to another point is a single hop ( jump ). Message Switching means switch over of a Message. In one step of Message Switching,  Message switches over from one node to another.  The two nodes involved in a Switching operation are on the same Network. It cannot be that the beginning node ( source node) is on one Network and the second node ( sink node ) is on a different Network. In a point to point ( one junction to another junction ) transmission, a Message travels a part of its journey. Message moves from previous point to next point. The Network is Point-to-Point Network. A Switching activity means movement of a message. Indeed, the Message has mov...