Friday, July 12, 2019

Tokens and Reserved Keywords in C language

Tokens and Reserved  Keywords in

 C language

Tokens and Reserved  Keywords in  C language

Keywords are pre-defined words in a C compiler. Each keyword is meant to perform a specific function in a C program. Since keywords are referred names for compiler they can’t be used as variable name.

C language supports 32 keywords which are given below:

  1. auto
  2. int
  3. const
  4. short
  5. break
  6. long
  7. continue
  8. signed
  9. double
  10. struct
  11. float
  12. unsigned
  13. else
  14. switch
  15. for
  16. void
  17. case
  18. register
  19. default
  20. sizeof
  21. char
  22. return
  23. do
  24. static
  25. enum
  26. typedef
  27. goto
  28. volatile
  29. extern
  30. union
  31. if
  32. while


Tokens:

C tokens are the basic building blocks in C language which are constructed together to write a C program. Each and every smallest individual units in a C program are known as C tokens.

C tokens are of six types, they are,

1.     keywords (e.g. : int, while),
2.     Identifiers (eg: main, total),
3.     Constants (eg: 10,20),
4.     Strings (eg: “total”,”hello”),
5.     Special symbols (eg: (),{}),
6.     Operators (eg: +,-,/,*)

C token example program:

int main()
{
int x,y,total;
x=10, y=20;
total=x+y;
printf(“total=%d\n”,total);
}

where,
main – Identifier
(),{} – special symbols
int – keyword
x,y,total – Identifiers
main,int, x,y, total,{},() – tokens

Labels: