A token can be a keyword, an identifier, a constant, a string literal, an operator, or a special symbol. The C compiler recognizes and interprets the sequence of tokens in a program.
Here are the types of tokens in C:
Here’s an example program that demonstrates some of the tokens in C:
#include
int main()
{
int num1 = 10, num2 = 20;
int sum = num1 + num2;
printf("The sum of %d and %d is %d\n", num1, num2, sum);
return 0;
}
In this program, the tokens include keywords (int, return), identifiers (main, num1, num2, sum), constants (10, 20), assignment operator (=), arithmetic operator (+), string literal (“The sum of %d and %d is %d\n”), special symbols (;, ,, (), {}, []), and function calls (printf).
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.