Rules for constructing variable and character constant

Rules for constructing CHARACTER CONSTANT:-

  • A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. 
  • The maximum length of a character constant can be 1 character. Ex: 'A' , 'I' , '5' , '='.
Rules for constructing VARIABLE NAMES:-
      In C language, any user defined variable name is called identifier. This may be variable names, function names, goto label name, any other data type like structure, union,enum names or typedef name.
  • A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some compilers allow variable names up to 247 characters. 
  • The first character in the variable name must be an alphabet or underscore.
  • No special symbol other than an underscore (as in gross_sal) can be used in a variable name. Ex:- rate, time, si_int, m_hra, bas_sal, etc.
  • Keywords should not be used as variable names because  if we do so, we are trying to assign a new meaning to the keyword, which is not allowed by the computer.

Post a Comment

0 Comments