Tuesday, 30 August 2016

C language identifiers and comments || identifiers Rules

Identifiers, as the name suggests helps us to identify data and other objects in the program. Identifiers are basically the names given to program elements such as variables, arrays, and functions. They may consist of an alphabet, digit, or an underscore.

Rules for Forming Identifier Names

Some rules have to be followed while forming identifier names. They are as follows:

  • It cannot include any special characters or punctuation marks(e.g.,#,$,^,?,., etc.) except the underscore ‘_’.
  • There cannot be two successive underscores.
  • Keywords cannot be used as identifiers.
  • The case of alphabetic characters that form the identifier name is significant. For example, ‘FIRST’ is different From ‘first’ and first’.
  • The identifiers name must begin with an alphabet or an underscore.
  • Identifiers can be of any reasonable length. They should not contain more than 31 characters.
  • Examples of valid identifiers include the following:
            Roll_number, marks, name, emp_number, Roll No, EMP_NO. . .
            Examples of invalid identifiers include:
            23_student, %marks, @name, #emp_number. . .

Comments in C

Many a time the meaning or the purpose of the program code is not clear to the reader. Therefore, it is a good programming practice to place some comments in the code to help the reader understand the code clearly. Comments are just a way of explaining what a program does. It is merely internal program documentation. The compiler ignores the comments when forming the object file. This means that the comments are non-executable statements. C supports two types of commenting.
  • // is used to comment a single statement. This is known as a line comment. A line comment can be placed any where on the line and it does not require to be specifically ended as the end of the line automatically ends the line.
  • /* is used to commet multiple statements. A/* is ended with */ and all statements that lie with in these characters are commented. This type of comment is known as block comment.


Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

python tutorial


C Programming


Java Tutorial


Data Structures


MS Office


Database Management