Variables and Rule of variables

In this Tutorial We learn about Variables and it's Rules

Variables in C

In a typical C program we have to do a lot of computation. Of course there will be storing of some data in different locations of memory in computer. These memory locations are identified by their address like 56234. Suppose if programmer wants to access the particular locations like 10 times in a program to store another value at that location.
So It will become a tedious job for a programmer if he have to memorise the numerical address name. So to make this job easy we use variables.
So variables are nothing but the name of the locations or addresses of memory which is given by programmer.

what is variable? A variable is an identifier or name which is used to refer a value and this value changes during the execution of the program. ANSI standard recognizes a length of 31 characters. A variable name can be chosen by the programmer in a meaningful way so to reflect its function or nature in the program. Example: Average, height, tot_amt, _amt, etc.



Rules For Variable 1.Every variable name should start with underscore(_) or alphabets(A-Z or a-z). 2.Spaces are not allowed in variable declaration. 3.Except for Underscore(_), no other special symbol is allowed in between variable declaration 4.A variable is written with a combination of numbers, letters and special characters that are underscore(_). 5.You Can’t used Any other Reserved Key word as a variable name at variable declaration time.


Syntax For Variable declaration:-
  <data-type> <var_name>;
Example:- int a;
Syntax For variable Initialization:-
  <var_name>=<value>;
Example:-  int a;
        a=10;
Syntax For variable Initialized with variable declaration:-
  <data-type> <var_name> = <value>;

Example:- int a=10;

Comment below if you have any queries related to the above tutorial for an Variables and 
Rule of variables in C programming language.


Post a Comment

0 Comments