VARIABLES



VARIABLES


variables  are simply the name given to a particular memory location , so that its content can be used effectively  throughout the program.

we can visualize variable as simple boxes with some name whose contents can be altered.
Values can be assigned to variable using the assignment operator('=').


There are two types of variables:-

1>GLOBAL VARIABLES :- variables which are declared before main function and  are accessible throughout the program.

2>LOCAL VARIABLES :- variables which are declared inside a function and are accessible inside that function body only.



RULES FOR VARIABLE DECLARATIONS :-

1> Should not match with any keywords .
2> It should always start with a letter.
3> only underscore('_') is allowed as a special symbol , no spaces allowed.


examples:-


             Valid variable names                                                   Invalid variable names
              hello_world                                                                       _helloworld
              hello123world                                                                     123helloworld
              hello_123world                                                                   1helloworld











Comments

Popular Posts