

{"id":54776,"date":"2019-04-20T13:50:37","date_gmt":"2019-04-20T08:20:37","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=54776"},"modified":"2019-07-03T15:51:18","modified_gmt":"2019-07-03T10:21:18","slug":"c-basic-syntax-rules","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/","title":{"rendered":"C Syntax Rules &#8211; Learn the ABCs of Programming in C Language"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1586,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/C_syntax&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251011092843\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/C_syntax&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 12:21:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-16 07:14:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-20 04:50:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-23 09:42:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-27 18:13:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-01 17:07:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-05 09:22:14&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-09 19:33:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-15 17:31:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-19 08:28:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-22 13:09:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-25 16:01:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-30 05:11:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-02 05:39:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-05 05:48:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-08 20:06:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 23:12:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 15:07:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-21 17:50:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 20:39:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 06:03:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-05 04:19:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-10 17:49:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 09:54:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-19 13:53:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-23 14:17:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 16:30:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-29 18:14:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-06 00:22:57&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-09 07:19:14&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-04-12 09:10:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-17 16:16:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 20:32:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-25 05:58:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-28 07:06:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-02 10:21:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-06 13:35:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-10 13:19:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-13 14:18:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-17 11:33:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-22 05:17:13&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-05-26 00:53:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-31 03:52:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-03 16:23:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-08 16:20:58&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-08 16:20:58&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>In this tutorial, we will be discussing the C syntax\u00a0in detail. If you have gone through our previous tutorials you might have understood the importance of <strong><a href=\"https:\/\/data-flair.training\/blogs\/c-tutorial\/\">C language<\/a><\/strong>.<\/p>\n<p>We will now focus on the syntax and the program structure in C. We will not be discussing any complex program code at this stage. Hence, this tutorial will help you start with a basic C program in a precise manner. At the end of this tutorial, you will be able to\u00a0explain each line of code.<\/p>\n<p>So, let&#8217;s start today&#8217;s journey with C basic Syntax.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-54823\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg\" alt=\"Syntax of C Programming Language\" width=\"802\" height=\"420\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg 802w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax-520x272.jpg 520w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<h2>C Basic Syntax<\/h2>\n<p><em>Syntax basically\u00a0refers to the protocols to be followed while writing a program<\/em>. It is very\u00a0necessary to follow proper syntax while coding to get the desired set of output. The\u00a0 C basic syntax consists of header files, main function, and program code. This is the most fundamental structure in the C program.\u00a0A C program necessarily consists of the main function because the execution of the program starts from this line. Without the main function, the program execution does not start.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include&lt;stdio.h&gt;\r\nint main() \/\/ main function with integer return type\r\n{\r\nprintf(\"Welcome to DataFlair tutorials!\\n\"); \/\/ print statement to display output on the screen\r\nreturn 0; \/\/ Indicates that the main function returns null value\r\n}<\/pre>\n<p><em><strong>Do you know what is the <a href=\"https:\/\/data-flair.training\/blogs\/features-of-c\/\">reason behind the popularity of C<\/a>?<\/strong><\/em><\/p>\n<p><strong>Code on Screen-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57377\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax.jpg\" alt=\"C Basic Syntax with Example\" width=\"1304\" height=\"659\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax.jpg 1304w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax-150x76.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax-300x152.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax-768x388.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax-1024x517.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-C-Basic-Syntax-520x263.jpg 520w\" sizes=\"auto, (max-width: 1304px) 100vw, 1304px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57378\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax.jpg\" alt=\"C Basic Syntax with Output\" width=\"1302\" height=\"672\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax.jpg 1302w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax-150x77.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax-300x155.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax-768x396.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax-1024x529.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-C-Basic-Syntax-520x268.jpg 520w\" sizes=\"auto, (max-width: 1302px) 100vw, 1302px\" \/><\/a><\/p>\n<p>From the above C syntax, we understood the placing of these elements. Now, let&#8217;s discuss\u00a0each element of the above code in depth.<\/p>\n<h3>1. Header Files<\/h3>\n<p>In the above code, we have used two header files.<\/p>\n<p><strong>#include &lt;stdio.h&gt;<\/strong><\/p>\n<p><strong>#include&lt;conio.h&gt;<\/strong><\/p>\n<p>C has a series of predefined functions embedded in the header files in the C library. We use these functions to perform a specific task with the help of a header file.<\/p>\n<p><strong>What are header files?<\/strong><\/p>\n<p>Header files contain a bunch of files that help the user to include the predefined functions according to his requirements. You can add header files using the preprocessor directive <strong>#include.<\/strong><\/p>\n<p><em><strong>You can <a href=\"https:\/\/data-flair.training\/blogs\/header-files-in-c\/\">create your own header file in C<\/a> within seconds<\/strong><\/em><\/p>\n<h3>2. Main Function<\/h3>\n<p>When your operating system runs a program in C, it gives the control of the computer to the C program.\u00a0If a program consists of only one line of code in the main function, then the program can run successfully.<\/p>\n<p>As the program execution starts from this line, it becomes compulsory for every C program to have the main function.<\/p>\n<ul>\n<li><strong>clrscr() &#8211;\u00a0<\/strong>This function\u00a0is predefined in the header file <strong>&lt;conio.h&gt;<\/strong>. clrscr() helps to clear the screen.<\/li>\n<li><strong>printf()<\/strong> &#8211; This is another function that helps you to display the message on the output screen. This function is defined in <strong>&lt;stdio.h&gt;.<\/strong> In the above program, it is pretty clear that the printf() function helps you display the output message: \u201cWelcome to DataFlair\u201d.<\/li>\n<li><strong>getch()<\/strong> &#8211; This function is defined in conio.h and is used to hold the output screen until we hit the next key after we run the program.<\/li>\n<\/ul>\n<p>This was a line to line description of the simplest code that can be built in C. With this, you might be clear with the flow of a C <a href=\"https:\/\/en.wikipedia.org\/wiki\/C_syntax\">syntax<\/a>. We will further discuss more complex programs in the simplest form of our upcoming C tutorials.<\/p>\n<h3>3. Tokens in C<\/h3>\n<p>A C syntax\/program consists of a series of tokens. They can be identifiers, variables, symbols. We can say that\u00a0they are<em> the smallest units of a program that convey a specific meaning to the compiler<\/em>. There are 5 <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/tokens-in-c\/\">types of tokens in the C language<\/a><\/strong><\/em>. They are :<\/p>\n<ol>\n<li>Keywords<\/li>\n<li>Identifiers\/Variables<\/li>\n<li>Constants<\/li>\n<li>Punctuators<\/li>\n<li>Operators<\/li>\n<\/ol>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-54806\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C.jpg\" alt=\"Elements of Token in C programming\" width=\"802\" height=\"421\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C.jpg 802w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C-768x403.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Tokens-in-C-520x273.jpg 520w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<h4>3.1\u00a0 Keywords in C<\/h4>\n<p><em>Keywords are a set of words used for a special purpose in the program<\/em>. They are reserved words. Some examples are for, while, switch, break, goto, etc.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include&lt;stdio.h&gt;  \r\nint main()\r\n{\r\nfor(int i=0;i&lt;3;i++)\r\n{\r\nprintf(\"Welcome to DataFlair tutorials!\\n\");\r\n}\r\nreturn 0;\r\n};<\/pre>\n<p><strong>Code on Screen-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57388\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C.jpg\" alt=\"Example of Keywords in C\" width=\"1307\" height=\"638\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C.jpg 1307w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C-150x73.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C-300x146.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C-768x375.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C-1024x500.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Example-of-Keywords-in-C-520x254.jpg 520w\" sizes=\"auto, (max-width: 1307px) 100vw, 1307px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p>In this example, we have used a keyword to print a message using the<strong> printf() <em><a href=\"https:\/\/data-flair.training\/blogs\/functions-in-c\/\">function in C<\/a><\/em><\/strong>.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57389\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C.jpg\" alt=\"Example of Keywords in C\" width=\"1301\" height=\"687\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C.jpg 1301w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C-768x406.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C-1024x541.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-keywords-in-C-520x275.jpg 520w\" sizes=\"auto, (max-width: 1301px) 100vw, 1301px\" \/><\/a><\/p>\n<h4>3.2 Variables in C<\/h4>\n<p>It is a<em> data item in the program whose value can be changed<\/em> and thus, it is called variable. They are a combination of letters and digits.<\/p>\n<p><strong>Rules for naming identifiers or variables<\/strong><\/p>\n<ul>\n<li>No special character can be used to name a variable except underscore(_).<\/li>\n<li>The variable name cannot start with a digit, it can be a letter or an underscore.<\/li>\n<li>No keyword can be used as an identifier.<\/li>\n<\/ul>\n<p><em><strong>Don&#8217;t forget to check, <a href=\"https:\/\/data-flair.training\/blogs\/variables-in-c\/\">how to initialize, declare and access variables in C<\/a><\/strong><\/em><\/p>\n<h4>3.3 Constants in C<\/h4>\n<p><em>Constants are those values that cannot be changed during program executio<\/em>n.<\/p>\n<h4>3.4 Punctuators in C<\/h4>\n<p><em>Punctuators are used for formatting the C program statements and expressions<\/em>.<\/p>\n<p>Examples for punctuators are : [ ] { } ( ) , ; : * =<\/p>\n<p>Let us talk about one of the punctuators i.e., semicolons<\/p>\n<p>A semicolon is used to show the ending of a statement. It acts as a separator between two statements. If you miss this statement at the end of any line, the compiler would join the statement with the next line of code and will give a<strong> syntax error<\/strong>.<\/p>\n<h4>3.5 Operators in C<\/h4>\n<p>There are various<em><strong><a href=\"https:\/\/data-flair.training\/blogs\/operators-in-c\/\"> operators in C<\/a><\/strong><\/em>\u00a0that we use in order to\u00a0<em>perform different mathematical operations<\/em>. They are:<\/p>\n<ul>\n<li>Arithmetic Operators\u00a0: +, -, *, \/<\/li>\n<li>Increment\/Decrement Operators\u00a0: ++,\u2013<\/li>\n<li>Relational Operators: ==, &lt;, &gt;, &lt;=, &gt;=, !=<\/li>\n<li>Logical operators : &amp;&amp;, ||, !<\/li>\n<li>Conditional Operators : ?:<\/li>\n<\/ul>\n<h3>4. Comments in C<\/h3>\n<p>A comment is a simple text that makes your code more descriptive and readable. You can add comments in your code just to explain how the code is functioning. Comments aren\u2019t a necessary part of a code, you can add them according to your convenience.<\/p>\n<p>There are two types of comments:<\/p>\n<ol>\n<li>Single line comments<\/li>\n<li>Multi-line comment<\/li>\n<\/ol>\n<p>For single line comment just put \u2018\/\/\u2019 before the comment line<\/p>\n<p>For multi-line comment \/*&#8212;&#8211;*\/\u00a0, the statements of comment should be enclosed within \/* and *\/.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include&lt;stdio.h&gt;   \r\nint main()\r\n{\r\nprintf(\"Welcome to DataFlair tutorials!\\n\"); \/\/ This is a single line comment\r\n\/* This is a multi-line comment *\/\r\n};<\/pre>\n<p><strong>Code on Screen-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57390\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example.jpg\" alt=\"Example of Comments in C\" width=\"1302\" height=\"669\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example.jpg 1302w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example-150x77.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example-300x154.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example-768x395.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example-1024x526.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Comments-in-C-with-example-520x267.jpg 520w\" sizes=\"auto, (max-width: 1302px) 100vw, 1302px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57391\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C.jpg\" alt=\"Output of Comments in C\" width=\"1299\" height=\"703\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C-150x81.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C-300x162.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C-768x416.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C-1024x554.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Output-of-Comments-in-C-520x281.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<h3>5. Whitespaces in C<\/h3>\n<p>In a C program, whitespace is generally\u00a0a blank line. The C programming language uses\u00a0whitespaces to describe blanks, newline characters, and comments.<\/p>\n<p>Whitespace separates one statement from another statement for the compiler to identify. In this statement,<\/p>\n<p><strong>int data ;<\/strong><\/p>\n<p>If you don\u2019t provide proper whitespace within the statements where it is needed, then the compilation will not be correct and you will not be able to get the desired output.<\/p>\n<p><strong>For example:<\/strong> If you have not provided whitespace between int and data, then it would create a compilation error.<\/p>\n<p><em><strong>Master the <a href=\"https:\/\/data-flair.training\/blogs\/basic-structure-of-c-program\/\">structure of C program<\/a> in just 7 mins<\/strong><\/em><\/p>\n<h3>6. Semicolons in C<\/h3>\n<p>Semicolons are\u00a0<em>provided to terminate the statement<\/em>. A Semicolon indicates the start and end of statement execution.<\/p>\n<p>This tells the compiler that the statement is completed. If a semicolon is not placed at the end of a statement, then the program will not compile generating a compilation error message.<\/p>\n<p>In the above code, all the statements within the function terminate with a semicolon. If the semicolon is not provided, it will generate \u201cCompilation Error\u201d.<\/p>\n<h2>Rules for a Program in C<\/h2>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Rules-for-C-Synatx.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-54798 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Rules-for-C-Synatx.jpg\" alt=\"Rules for Coding in C\" width=\"512\" height=\"223\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Rules-for-C-Synatx.jpg 512w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Rules-for-C-Synatx-150x65.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/Rules-for-C-Synatx-300x131.jpg 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<ol>\n<li>C is a case sensitive language. Most of the program statements are in lower case.<\/li>\n<li>All statements must necessarily\u00a0terminate with a semicolon.<\/li>\n<li>Whitespaces should be provided only between variables and keywords.<\/li>\n<\/ol>\n<h2>Summary<\/h2>\n<p>We hope you understood the basic syntax of the C programming language with the program structure. Now, you can easily apply tokens, keywords, comments and other essential elements of C language in your program.\u00a0These elements of the C syntax play a very important role in programming in C and makes you proficient in the C programming language.<\/p>\n<p><em><strong>Do you know the<a href=\"https:\/\/data-flair.training\/blogs\/preprocessors-in-c\/\"> importance of preprocessors in C<\/a>?<\/strong><\/em><\/p>\n<p>If you have any queries related to this topic, please ask in the comment box below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will be discussing the C syntax\u00a0in detail. If you have gone through our previous tutorials you might have understood the importance of C language. We will now focus on the&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":54823,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19488],"tags":[19557,19558,19559,19560],"class_list":["post-54776","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-c-basic","tag-c-syntax","tag-rules-for-c","tag-s-syntax-basics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C Syntax Rules - Learn the ABCs of Programming in C Language - DataFlair<\/title>\n<meta name=\"description\" content=\"Wnat to learn programming in C, but don&#039;t know the syntax of C? Let&#039;s learn togather its rules, basics and parts- header files, main function, token in c\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C Syntax Rules - Learn the ABCs of Programming in C Language - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Wnat to learn programming in C, but don&#039;t know the syntax of C? Let&#039;s learn togather its rules, basics and parts- header files, main function, token in c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-20T08:20:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-07-03T10:21:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C Syntax Rules - Learn the ABCs of Programming in C Language - DataFlair","description":"Wnat to learn programming in C, but don't know the syntax of C? Let's learn togather its rules, basics and parts- header files, main function, token in c","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/","og_locale":"en_US","og_type":"article","og_title":"C Syntax Rules - Learn the ABCs of Programming in C Language - DataFlair","og_description":"Wnat to learn programming in C, but don't know the syntax of C? Let's learn togather its rules, basics and parts- header files, main function, token in c","og_url":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-04-20T08:20:37+00:00","article_modified_time":"2019-07-03T10:21:18+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"C Syntax Rules &#8211; Learn the ABCs of Programming in C Language","datePublished":"2019-04-20T08:20:37+00:00","dateModified":"2019-07-03T10:21:18+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/"},"wordCount":1249,"commentCount":11,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg","keywords":["C Basic","C syntax","Rules for C","S syntax basics"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/","url":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/","name":"C Syntax Rules - Learn the ABCs of Programming in C Language - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg","datePublished":"2019-04-20T08:20:37+00:00","dateModified":"2019-07-03T10:21:18+00:00","description":"Wnat to learn programming in C, but don't know the syntax of C? Let's learn togather its rules, basics and parts- header files, main function, token in c","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/04\/C-syntax.jpg","width":802,"height":420,"caption":"Syntax of C Programming Language"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/c-basic-syntax-rules\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"C Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/c-programming\/"},{"@type":"ListItem","position":3,"name":"C Syntax Rules &#8211; Learn the ABCs of Programming in C Language"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/54776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=54776"}],"version-history":[{"count":12,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/54776\/revisions"}],"predecessor-version":[{"id":61927,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/54776\/revisions\/61927"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/54823"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=54776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=54776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=54776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}