Token in C Language| Types of Token in C Language

 Token in C Language| Types of Token in C Language

Token in C Language| Types of Token in C Language | Tech A Khan


What is a Token In C language?

Token is the smallest unit in a program. It is related to each and every words and character of C program. So, compiler spilt the program in smallest possible unit, compile the every stage of program. 

There are 5 types of Token:

  1. Keywords
  2. Operators
  3. String
  4. Constants
  5. Identifier
  6. Special Character. 

What is a Keywords in C language? 

Keywords are parts of syntax of C language which are reserved and predefined words used in C programming syntax that give special instructions to the compiler to perform defined function. it means that, meaning keywords have already defined in C compiler. there are 32 reserved keyword in C. examples are given below... 

32 Keywords of C language

S.NoKeywordsKeyword TypesDescription
1.intData typesIt is related to the integer type of data. 
2.charData typesIt is related to the character type of data.
3.doubleData typesIt is related to the decimal number with double-precision. 
4.floatData typesIt is also related to the decimal number, but with single-precision. 
5.shortQualifiersIt is related to the fairly small integer types of data.
6.longQualifiersIt is related to the fairly large integer types of data. 
7.signedQualifiersIt is related to the positive and negative integer types of data. 
8.unsignedQualifiersIt is related to the only positive integer types of data. 
9.typedefUser-definedIt is used to define a new name for an existing data types.
10.enumUser-definedIt gives an opportunity to user-intent data type and define which types of data  can take in variables.
11.forLoopIt is used when a block of code is executed fixed number of times.
12.doLoopIt is used when a block of code to be executed a least once or repeatedly.
13.whileLoopIt is used when a block of code is to executed a variable number of times.
14.ifDecisionIt is related to 'Boolean Expression' if statement is 'true' the block of code inside 'if' statement is executed. 
15.elseDecisionIt is also related to 'Boolean Expression' if statement is 'False' the block of code inside 'else' statement is executed.
16.switchDecisionIt is related to type of selection control mechanism which is used to allow the expression to change the control flow of the program execution. 
17.caseDecisionit is part of switch and it is related to selection mechanism which is used to allow specific expression to control flow of program execution.
18.defaultDecisionIt is executed when no case expression value is match to value of expression. 
19.continueJumpIt is related to control the nearest enclosing loop. 
20.breakJumpIt is related to terminate the nearest loop. 
21.gotoJumpIt is related to jump or transfer from loop or statements to another statement.
22.voidFunctionIt is pointer declaration and indicate that the function does not return value. 
23.returnFunctionIt is related to the control the calling function,. 
24.structDerivedIt is related to the composite data type which declare the physically grouped list of variable under one name in a block of memory. 
25.unionDerivedIt is related to User-defined data types. It collects variable of different data types in the same memory location. 
26.autoStorage classesIt is related to storage class and used to declare a local variable. 
27.registerStorage classesIt indicate the compiler to use register as a memory for a variable instead of RAM.
28.staticStorage classesIt is related to restrains  visibility of function and multiple function call. 
29.externStorage classesIt is use to declare a global variable without any memory assigned to it. 
30.constOtherIt is never change value during execution once defined. 
31.volatileOtherIt is a qualifier that declare a variable in source code. 
32.sizeofOtherit is generate storage size of data types or an expression. 

Some Important Point Of Keywords in C Language:

  • C language is case sensitive language, all keywords must be written in lower case. 
  • There are 32 keywords in C language. 
  •  Keywords are reserved and predefined words and their meaning cannot be changed.
  • Keywords cannot be used as user-intent or User-defined variable. 
  •  Keywords are basics building block of programming syntax. 

What is an Operators in C language?

In C language, Operator is a special type of symbol that tells the compiler or interpreter to perform specific mathematical and logical operations. C language is enrich in set of operators.

There are mainly 5 types of operators in C languages:

  1. Arithmetic Operators
  2. Relational Operators
  3. Logical Operators
  4. Bitwise Operators
  5. Assignment Operator

Some Other operator in C Language:

  1. Sizeof Operator
  2. Comma Operator
  3. Conditional Operator

What is a String in C language? 

String is a sequence/array of characters or literals which is terminated or followed by null character ('/0' ) and set of character surrounded by double quotation marks. 
For example-- char c[ ] = "C string". 

What is a Constant in C language? 

A constant is a fixed value or literal that can't be changed during the program execution. It is fundamental and essential parts of basic data types in C program.

Types of C Constant:

  1. Decimal Constant
  2. Real or Floating point Constant
  3. Octal Constant
  4. Hexadecimal Constant
  5. Character Constant
  6. String Constant  

What is a Variables in C language? 

Variable is a value location memory or data storage area, which is used to store to set of expression data and each variable has specific types, which determine the size and layout of variable. It's value can be changed before execution and it can be reused many time and easily identify. 

There are 5 types of variables.

  • local variable
  • global variable
  • static variable
  • automatic variable
  • external variable

Important Point:

  • A variable have alphabets, digits and underscore. But it starts with alphabet and underscore. 
  • No whitespace is allowed within variable name. 
  • Variable is not work as reserved words. 

What is an Identifier in C language? 

An identifier is a combinations of alphanumeric characters that begins with either an alphabets characters or an underscore and remaining end alphabets character, numeric and underscore which represent the various elements like: function, array, structure, labels, etc.

Some Important Point:

  • At least first character of identifier is an alphabet or an underscore and followed by digits, characters and underscores. Because, it's  first character does not begin with number. 
  • Identifier does not specified the  Commas and whitespace. 
  • Keywords do not represent as an Identifier. 
  • An Identifiers are case sensitive (upper case and lower case). There are 52 alphabets characters(upper case and lower case), 10 numeric (0-9 numbers). 
  • The length of an Identifier can not more than 31 characters. If length of an Identifier is short and meaningful, easy to point bug or error for programmer. 

What is special character in  C language? 

Special character are sequence of special symbols. C language is enrich in  special character. 
For example-- # * $ %.... 

Post a Comment

0 Comments