Nearby lessons

9 of 72

C - Identifiers

Identifiers are the names you give to variables, functions, arrays and structures in C. Learn the naming rules, which names are illegal, and the conventions professional C programmers follow.

What is an Identifier?

An identifier is simply a name that you invent. Every time you declare a variable, define a function, or create a structure, you are choosing an identifier.

Example01
Loading editor…

The Five Rules

#RuleValidInvalid
1Letters, digits and underscore onlyscore_1score-1, my age
2Must not begin with a digita1, _a11a
3Cannot be a keywordintegerint, for
4No spaces or special symbolstotalMarkstotal marks, total@
5Case-sensitivesum ≠ Sum—
In simple words: letters, digits and underscores; never start with a digit; never use a keyword. That is the whole rule set.

Valid and Invalid Examples

Read each line and the reason beside it — this is the fastest way to internalise the rules:

Example03
Loading editor…

Case Sensitivity in Action

C treats a change of case as a completely different name. This program declares three separate variables:

Example04
Loading editor…

Naming Conventions Professionals Use

The compiler accepts any legal name, but readable code follows conventions:

  • Variables and functions — camelCase or snake_case: totalMarks, total_marks.
  • Constants and macros — UPPER_SNAKE_CASE: MAX_SIZE, PI.
  • Be descriptive — studentCount beats sc or x.
  • Loop counters — short names like i, j, k are traditional and fine.
  • Avoid leading underscores — names like _size and __x are reserved for the compiler and standard library.
Only the first 31 characters are guaranteed to be significant for internal names in C89. Two identifiers that differ only after character 31 may be treated as the same name by old compilers. Keep names well under that limit.
📝 Key Takeaways
  • An identifier is a user-defined name for a variable, function, array or type.
  • It may contain letters, digits and underscores only.
  • It must not start with a digit.
  • Keywords such as int and return cannot be identifiers.
  • C is case-sensitive: age, Age and AGE are three different identifiers.

🧠 Test Your Knowledge

4 Questions
Progress: 0 / 4

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.