Tokens in C

You have seen the basic structure of C program. C tokens are the basic buildings block in C language which are constructed together to write a C program. They are six types of tokens in C.

  • Keywords
  • Identifiers
  • Constants
  • Operators
  • Strings
  • Special Symbol
  • Keywords: A keywords is reserved word in C.These keywords you cannot use it as variables name, constant name and any other identifiers name. There are only 32 keywords in the C language.Keywords are pre-defined words in a C compiler.
  • Identifiers: In this C program identifiers is a name and it is used to identify a variable, functions,array,structures and any other user-defined items.Identifiers are composed of letters such as uppercase,lowercase letters, digit,underscore but the starting letter should be alphabet or underscore.
    Rules for Constructing Identifiers:-

    • First character of an identifier should be either alphabet or underscore.
    • After first character it can be followed by any of the digit,character.
    • Blank spaces and commas cannot be specified with in a identifier.
    • The length of the identifiers cannot be more than 31 character.
  • Constants: Constant is also a value or variable,but only difference is their values cannot be change by the program once they are defined.Constant are also referd a fixed values and constants may be belonging to any of the data type.
    There are two ways to declare constant :

    • Using const keyword
    • Using #define pre-processor
  • Operators: Operators in C is a special symbol that tells the compiler to perform specific mathematical or logical function. The data items on which those operators are applied are known as operands.
    The following is the list of the operators:

    • Arithmetic Operator
    • Relational Operator
    • Logical Operator
    • Bitwise Operator
    • Conditional operator
    • Assignment operator
  • Strings: In C programming, a string is a sequence of characters terminated with a null character \0. The null character denotes the end of the string.Characters are enclosed within single characters and string are enclosed within double quotes.
    String in different ways:-

    • char a[15] = “technicalfunda”; //the compiler allocates the 14 bytes to the ‘a’ array.
    • char a[] = “technicalfunda”; //The compiler allocates the memory at the run time.
    • char a[] = {‘t’,’e’,’c’,’h’,’n’,’i’,’c’,’a’,’l’,’f’,’u’,’n’,’d’,’a’,’\0′};
  • Special Symbol: some special characters are used in c, and they have important part of this C language and also have a special meaning which they cannot be used for another purpose.
    • Simple Brackets (): It is used in function declaration and function calling.
    • Comma(,) : It is used for separating for more than one statement.
    • Square Brackets [] :Opening and closing brackets represent the single and multidimensional subscripts.
    • Hash/pre-processor (#) : It is used for pre-processor directive.It is denotes that we are using header file.
    • Tilde (~) : It is used as a destructor to free memory.

Submit your review

Create your own review

The Technical Funda
Average rating:  
 0 reviews