Tokens in C - GeeksforGeeks
Tokens in C - GeeksforGeeks
Tokens in C - GeeksforGeeks
Tokens in C
A token in C can be defined as the smallest individual element of the C
programming language that is meaningful to the compiler. It is the basic
component of a C program.
Types of Tokens in C
The tokens of C language can be classified into six types based on the
functions they are used to perform. The types of C tokens are as follows:
1. Keywords
2. Identifiers
3. Constants
4. Strings
5. Special Symbols
6. Operators
1. C Token – Keywords
The keywords are pre-defined or reserved words in a programming
language. Each keyword is meant to perform a specific function in a
We useprogram. Sinceyoukeywords
cookies to ensure have the bestare referred
browsing names
experience on ourfor a compiler,
website. By using they can’t be
our site,
usedyou acknowledge
as variable thatnames
you havebecause
read and understood
by doing our Cookie
so, we Policy Privacy to assignGot
are& trying a Itnew
!
Policy
meaning to the keyword which is not allowed. You cannot redefine
keywords. However, you can specify the text to be substituted for keywords
before compilation by using C preprocessor directives. C language supports
32 keywords which are given below:
2. C Token – Identifiers
Identifiers are used as the general terminology for the naming of variables,
functions, and arrays. These are user-defined names consisting of an
arbitrarily long sequence of letters and digits with either a letter or the
underscore(_) as a first character. Identifier names must differ in spelling and
case from any keywords. You cannot use keywords as identifiers; they are
reserved for special use. Once declared, you can use the identifier in later
program statements to refer to the associated value. A special identifier
called a statement label can be used in goto statements.
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
06:10
For example,
3. C Token – Constants
The constants refer to the variables with fixed values. They are like normal
variables but with the difference that their values can not be modified in the
program once they are defined.
Examples of Constants in C
We use const
cookies toint
ensurec_var
you have=the20;
best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
const int* const ptr = &c_var;
Policy
4. C Token – Strings
Strings are nothing but an array of characters ended with a null character
(‘\0’). This null character indicates the end of the string. Strings are always
enclosed in double quotes. Whereas, a character is enclosed in single quotes
in C and C++.
Examples of String
char string[20] = {‘g’, ’e’, ‘e’, ‘k’, ‘s’, ‘f’, ‘o’, ‘r’, ‘g’,
’e’, ‘e’, ‘k’, ‘s’, ‘\0’};
char string[20] = “geeksforgeeks”;
char string [] = “geeksforgeeks”;
6. C Token – Operators
Operators are symbols that trigger an action when applied to C variables
and other objects. The data items on which operators act are called
operands.
Depending on the number of operands that an operator can act upon,
operators can be classified as follows:
Ternary Operator: The operator that requires three operands to act upon
is called the ternary operator. Conditional Operator(?) is also called the
ternary operator.
Here's a complete roadmap for you to become a developer: Learn DSA ->
Master Frontend/Backend/Full Stack -> Build Projects -> Keep Applying
to Jobs And why go anywhere else when our DSA to Development: Coding
Guide helps you do this in a single program!
Apply now to our DSA to Development Program and our counsellors will
connect with you for further guidance & support.
Maximize your earnings for your published articles in Dev Scripter 2024! Showcase
We use cookies to ensure you have the best browsing experience on our website. By using
expertise,
our site, gain recognition
you acknowledge & get
that you have read andextra compensation
understood while
our Cookie Policy elevating your tech
& Privacy
profile. Policy
Last Updated : 03 Jul, 2023 445
Previous Next
C Comments Keywords in C
Similar Reads
C program to detect tokens in a C
program
I I.HARISH KUMAR
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Careers GfG Weekly Contest
In Media Offline Classes (Delhi/NCR)
Contact Us DSA in JAVA/C++
Advertise with us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL DSA Interview Questions
R Language Competitive Programming
Android Tutorial
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy