Tokens in C programming

In this page, we will learn about: What are tokens in C programming?, What are the keywords in C programming?, What is the identifier in C programming? , What are the constants in C programming? What are strings in C programming? What are the special symbols in C programming? What are the operators in C programming?


What is tokens in C programming?

Tokens are some of the most significant components utilized in the C programming language. Tokens in C are the smallest individual components of a program that are relevant to the operation of a compiler.

A token is the smallest unit of measurement in a C program. Every punctuation mark and word in a C program is a token. A compiler converts a C program into tokens before moving on to the next steps of the compilation process.

Tokens are:-

1. Keywords 2. Identifiers
3. Constants 4. Strings
5. Special symbols 6. Operators
tokens in c programming

1. What are the Keywords in c programming?

Keywords are reserved words in C that are connected with certain qualities. These terms assist us in utilizing the C language's capabilities. They have a specific significance for the compilers.

auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct _Packed
double

Here is an example:


  #include<stdio.h>
  int main() {
    // char, int and float are the keywords
    char c = 'H';
    int b = 6
    float d = 7.6;
    // if and else are the keyword
    if(b < 5){
     printf("Character Value is : %c",a1);
    }
    else{
     printf("Float value is : %f",d);
    }
    return 0;
  }

Output:


    Float value is : 7.600000  

2. What is the Identifier in C programming?

In C program An identifier is used to identify a variable, functions or a user defined items. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9) as well as you must remember C program case sensitive. So you need aware of using these stuffs.These are names given to variables, functions, or user-defined data types. An identifier can be any combination of letters, digits, and underscore, but it must start with a letter or underscore. Examples of identifiers in C include "sum", "count", "total_sales", and "calculate_area".

3. What are the Constants in c programming?

These are fixed values that do not change during the execution of a program. There are several types of constants in C, including integer constants, floating-point constants, character constants, and string literals. Examples of constants in C include "25", "3.14", "'A'", and ""Hello, World!"". Constants are some fixed values which does not change, just like math. Constants of C Programming Language are three types. They are:

  1. Numeric Constants
  2. Character Constants
  3. Special Output Constant

  int a, b;
  a = 10; //here 10 is constant
  b = 15; //here 15 is constant

4. What are Strings in c programming?

String is a set of caracters to more precise, an array of characters that ended with a null character is termed as a string. This null indicates the end of the string. Null character denotes by '\0\'. Some declarations for string are:


  printf("Hello");//here Hello is a String

5. What are the Special symbols in c programming?

We are write lots of symbol in your codes like differnt brackets, semicolons etc that is call special symbol


  int a;
  a = 5; // here ; is a symbol
  printf("%d",a); // here "" , and ; is symbol    

6. What are the Operators in c programming?

The Operators in c programming are those, who trigger an action when that is applied to c variables as well as other objects. Depending on the number of operands that an operator can do or act, operators can be classified into two divisions and operands are those data on which operators act upon.

  • Unary Operators: The operators which require only a single operand to act. For instance, the increment and decrement operators are unary operators.
  • Binary Operators: Operators that require two operands to act are termed as binary operators. Binary operators can be classified into six more classes. These are:
    1. Arithmetic Operators: +, -, *, /, %
    2. Relational Operators: ==, > , <, !=, >=, <=
    3. Logical Operators: &&, ||, !
    4. Assignments Operators: =, +=, -=, *=, /=, %=
    5. Conditional Operators: (expression) ? value_if_true : value_if_false;
    6. Bitwise Operators: &, |, ^, ~, <<, >>

  int a;
  a = 5; // here = is a assignment operator


Extra lesson


What is Semicolons in c programming?

A Semicolons is called line terminator. Every individual line must terminate with Semicolons. For an example:


  printf("hello");
  return 0;

What is Comments in c:

Comments are used for helping others people who are going read or trying to understand your codes.There are two types of comments available in C Program.
1. Single Line Comments. It starts with //
2. Multiline Comments.It Starts with /* and ends with */


  int b; //this is single line comment
  /* this is multiline 
  comment */