Professional Documents
Culture Documents
Keywords and Identifiers in C
Keywords and Identifiers in C
Keywords and Identifiers in C
programmerdouts.blogspot.com/2019/06/learn-basic-concept-of-c-language.html
KEYWORDS IN 'C'
C has 32 reserved keywords
Since keywords has specific meaning, we cannot use them as identifiers
all keywords are written in lowercase(small letters) letters
keywords
Identifiers in C
They are used for naming variables, functions and arrays. which character sequences
constitute identifiers depends on the lexical grammar of the language. A common rule is
alphanumeric sequences, with underscore also allowed, and with the condition that it not
begin with a digit (to simplify lexing by avoiding confusing with integer literals) – so fun,
fun5, fuc_bars, _fun are allowed, but 1foo is not – this is the definition used in earlier
versions of C and C++, Python, and many other languages. Later versions of these
languages, along with many other modern languages, support almost all Unicode characters
in an identifier. However, a common restriction is not to permit whitespace characters and
language operators; this simplifies tokenization by making it free-form and context-free. For
example, forbidding + in identifiers due to its use as a binary operation means that a+b and
a + b can be tokenized the same, while if it were allowed, a+b would be an identifier, not an
1/3
addition. Whitespace in identifier is particularly problematic, as if spaces are allowed in
identifiers, then a clause such as if rainy day then 1 is legal, with rainy day as an identifier,
but tokenizing this requires the phrasal context of being in the condition of an if clause.
Some languages do allow spaces in identifiers, however, such as ALGOL 68 and some
ALGOL variants – for example, the following is a valid statement: real half pi; which could be
entered as .real. half pi; (keywords are represented in boldface, concretely via stropping). In
ALGOL this was possible because keywords are syntactically differentiated, so there is no
risk of collision or ambiguity, spaces are eliminated during the line reconstruction phase,
and the source was processed via scannerless parsing, so lexing could be context-sensitive.
Identifiers Rules
alphabets ,digits, underscores and dollor signs are allowed
They should not return with an digit
First word should be letter
identifiers are case-censitive
which means(uppercase letter and lower case letter are two different thing)
eg: AVG and avg both will be consider as two different variables
keywords/reserved words cannot be used as variable
they may begin with underscore character
_salary emp salary even " " space charater is not allowed
identifiers
Further Concepts
2/3
What are data types ?
What are Variables?
What are Constant?
what are Escape Sequences?
keyword 'const'
different types of declaring constants
Operators In C
Simple Practice Programs
3/3