Skip to main content

Variable: Declaration, initialization and Usage


Variable

Variables are the names given to some memory location where a value is stored; the variable is corresponding to the data or value input in it.

source: http://diwo.bq.com/wp-content/uploads/2014/12/Variables-en-Arduino.jpg


RULES FOR DEFINING A VARIABLE / VARIABLE NAME:

  • · A Variable name should not have name of any KEYWORDS in C.
  • · A Variable name can be alphanumeric but should start with an Alphabet.
  • · A Variable name should not consist of any special symbol other than “_” Underscore Symbol. 
  • · A Variable should be defined before using it.

VARIABLE DECLARATION:

In this step, the variables are declared, this steps always occurs before using the variables.

FORMAT:



 EXAMPLE:



VARIABLE INITIALIZATION:

Providing a Value to any variable is called initialization.


INITIALIZATION AT THE TIME OF DECLARATION:


The variable can be given its value at the time of declaration.


USAGE OF VARIABLE:

Here is the example, to show how a variable is used in formulas to find out some values:




Comments