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

Longest Absolute Path in File System Representation

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

4 days ago

Efficient Order Log Storage

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

2 weeks ago

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

3 weeks ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

1 month ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

1 month ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or…

1 month ago