Rules for declaring variable

Rules for declaring variable

To declare any variable in C language one must follow certain rules like:
  1. One must not use spaces in declaration of variables.
  2. Every variable should start from alphabet or underscore(_)
  3. Except underscore(_) no special characters is allowed.
  4. Variable must be at left side of assignment operator(=)
  5. No keyword must be declared as variable. For more information on keywords click here.
Examples of valid variables are:
int a= 2
float m =2.97

Examples of invalid variables are:

Variable name Reason for being invalid
int float = 2 float is keyword
int new number=89 Space not allowed
float variable&answer No Special characters except
underscore(_)

No comments:

Post a Comment