Categories: C

Identifiers in C

Identifiers in C are the basic building block of a program. As the name suggests, they are used to identify user-defined objects. For instance, variables, functions, arrays, structures, unions, labels, etc.
An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9).


Rules for composing an identifier in C:
  • Identifiers can have alphabets, digits, and underscore characters.
  • C does not allow punctuation characters such as @, $, and % within identifiers.
  • They must not be a keyword.
  • They must not begin with a digit.
  • Identifier length should not be more than 31 characters.
  • C is case sensitive in nature i.e., upper-case letters and lower-case letters are different.
  • Assign indicative names that make sense.

We can create any name as an identifier by following the given rules. Let’s take a look at some examples.

Valid identifiers examples:
variable1   app_2  _xyz  _XYZ  Rst sum1
Invalid identifiers example:
23a @var !$b 09xy
Some facts about identifiers:
  • Not all identifiers are variables.
  • It is created to give a unique name to an entity.
  • Identifiers are tokens.
  • Once declared, we can use the identifier in the later program.

Note: Also read about C Program – Structure & Keywords in C.

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Share
Published by
Rabecca Fatima

Recent Posts

What is object oriented design patterns

A design pattern is a reusable solution to a commonly occurring problem in software design. They…

4 months ago

Factory Method Design Pattern in OODP

Factory Method is a creational design pattern that deals with the object creation. It separates…

5 months ago

Find Intersection of Two Singly Linked Lists

You are given two singly linked lists that intersect at some node. Your task is…

10 months ago

Minimum Cost to Paint Houses with K Colors

A builder plans to construct N houses in a row, where each house can be…

10 months ago

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file…

11 months ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order…

11 months ago