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

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago