{"id":2315,"date":"2024-11-06T10:54:05","date_gmt":"2024-11-06T10:54:05","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.in\/?p=2315"},"modified":"2024-11-06T10:54:06","modified_gmt":"2024-11-06T10:54:06","slug":"tokens-in-c","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2024\/11\/06\/tokens-in-c\/","title":{"rendered":"Tokens in C"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Types of Tokens in C<\/h2>\n\n\n\n<p>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:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/media.geeksforgeeks.org\/wp-content\/uploads\/20230703154836\/Tokens-in-C.png\" alt=\"tokens in c\"\/><\/figure>\n\n\n\n<ol>\n<li><strong>Keywords<\/strong><\/li>\n\n\n\n<li><strong>Identifiers<\/strong><\/li>\n\n\n\n<li><strong>Constants<\/strong><\/li>\n\n\n\n<li><strong>Strings<\/strong><\/li>\n\n\n\n<li><strong>Special Symbols<\/strong><\/li>\n\n\n\n<li><strong>Operators<\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">1. C Token \u2013 Keywords<\/h2>\n\n\n\n<p>The\u00a0<a href=\"https:\/\/www.geeksforgeeks.org\/keywords-in-c\/\">keywords<\/a>\u00a0are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program.  However, you can specify the text to be substituted for keywords before compilation by using C preprocessor directives.\u00a0<strong>C<\/strong>\u00a0language supports\u00a0<strong>32<\/strong>\u00a0keywords which are given below:\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>auto         double      int        struct<\/strong><br><strong>break        else        long       switch<\/strong><br><strong>case         enum        register   typedef<\/strong><br><strong>char         extern      return     union<\/strong><br><strong>const        float       short      unsigned<\/strong><br><strong>continue     for         signed     void<\/strong><br><strong>default      goto        sizeof     volatile<\/strong><br><strong>do           if          static     while<\/strong><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. C Token \u2013 Identifiers<\/h2>\n\n\n\n<p>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. A special identifier called a statement label can be used in goto statements.\u00a0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Rules for Naming Identifiers<\/h3>\n\n\n\n<p>Certain rules should be followed while naming c identifiers which are as follows:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. C Token \u2013 Constants<\/h2>\n\n\n\n<p>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.&nbsp;<\/p>\n\n\n\n<p>Constants may belong to any of the data types.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Examples of Constants in C<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">const int c_var = 20;<br>const int* const ptr = &amp;c_var;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. C Token \u2013 Strings<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.geeksforgeeks.org\/strings-in-c\/\">Strings<\/a>&nbsp;are nothing but an array of characters ended with a null character (\u2018\\0\u2019). 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++.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Examples of String<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">char string[20] = {\u2018g\u2019, \u2019e\u2019, \u2018e\u2019, \u2018k\u2019, \u2018s\u2019, \u2018f\u2019, \u2018o\u2019, \u2018r\u2019, \u2018g\u2019, \u2019e\u2019, \u2018e\u2019, \u2018k\u2019, \u2018s\u2019, \u2018\\0\u2019};<br>char string[20] = \u201cgeeksforgeeks\u201d;<br>char string [] = \u201cgeeksforgeeks\u201d;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. C Token \u2013 Special Symbols<\/h2>\n\n\n\n<p>The following special symbols are used in C having some special meaning and thus, cannot be used for some other purpose. Some of these are listed below:<\/p>\n\n\n\n<ul>\n<li><strong>Brackets[]:<\/strong>&nbsp;Opening and closing brackets are used as array element references. These indicate single and multidimensional subscripts.<\/li>\n\n\n\n<li><strong>Parentheses():&nbsp;<\/strong>These special symbols are used to indicate function calls and function parameters.<\/li>\n\n\n\n<li><strong>Braces{}:<\/strong>&nbsp;These opening and ending curly braces mark the start and end of a block of code containing more than one executable statement.<\/li>\n\n\n\n<li><strong>Comma (, ):&nbsp;<\/strong>It is used to separate more than one statement like for separating parameters in function calls.<\/li>\n\n\n\n<li><strong>Colon(:):<\/strong>&nbsp;It is an operator that essentially invokes something called an initialization list.<\/li>\n\n\n\n<li><strong>Semicolon(;):<\/strong>&nbsp;It is known as a statement terminator. &nbsp;It indicates the end of one logical entity. That\u2019s why each individual statement must be ended with a semicolon.<\/li>\n\n\n\n<li><strong>Asterisk (*):&nbsp;<\/strong>It is used to create a pointer variable and for the multiplication of variables.<\/li>\n\n\n\n<li><strong>Assignment operator(=):&nbsp;<\/strong>It is used to assign values and for logical operation validation.<\/li>\n\n\n\n<li><strong>Pre-processor (#):&nbsp;<\/strong>The preprocessor is a macro processor that is used automatically by the compiler to transform your program before actual compilation.<\/li>\n\n\n\n<li><strong>Period (.):<\/strong>&nbsp;Used to access members of a structure or union.<\/li>\n\n\n\n<li><strong>Tilde(~):&nbsp;<\/strong>Bitwise One\u2019s Complement Operator.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">6. C Token \u2013 Operators<\/h2>\n\n\n\n<p>Operators\u00a0are symbols that trigger an action when applied to C variables and other objects. The data items on which operators act are called operands.\u00a0<\/p>\n\n\n\n<ul>\n<li><strong>Unary Operators:<\/strong>&nbsp;Those operators that require only a single operand to act upon are known as unary operators.For Example increment and decrement operators<\/li>\n\n\n\n<li><strong>Binary Operators:<\/strong>\u00a0Those operators that require two operands to act upon are called binary operators.<strong>&nbsp;<\/strong>Binary operators can further are classified into:\n<ol>\n<li>Arithmetic operators<\/li>\n\n\n\n<li>Relational Operators<\/li>\n\n\n\n<li>Logical Operators<\/li>\n\n\n\n<li>Assignment Operators<\/li>\n\n\n\n<li>Bitwise Operator<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><strong>Ternary Operator<\/strong>: The operator that requires three operands to act upon is called the ternary operator. Conditional Operator(?) is also called the ternary operator.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A token in C can be defined as the smallest individual element of the C&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/2315"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=2315"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/2315\/revisions"}],"predecessor-version":[{"id":2316,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/2315\/revisions\/2316"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=2315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=2315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=2315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}