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





There is no need of learning these keywords.
keywords
auto extern sizeof break float static
case for struct char goto switch
const if typedef continue int union
default long unsigned do register void
return double else while volatile short
enum signed sizeof











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 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

Some valid and invalid declarations

identifiers
valid Invalid Reason
a 6a first character should not contain digits
func1 "func1"" character is not valid
Roll_no Roll-no "-" character is not valid
_salary emp salary even " " space charater is not allowed
func4 func-4 "-" is not allowed
fun long "long" is the keyword