

{"id":59783,"date":"2019-06-18T17:20:19","date_gmt":"2019-06-18T11:50:19","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=59783"},"modified":"2019-06-24T10:52:42","modified_gmt":"2019-06-24T05:22:42","slug":"basic-c-programs","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/","title":{"rendered":"7 Basic C Programs that will help you to rise from Noob to Pro"},"content":{"rendered":"<p>If the roots of a tree are not strong, it would not be able to support the tree. Similarly, if you are not aware of some of the basic C Programs and you wish to be master C Programming, then you&#8217;re simply building castles in the air.<\/p>\n<p>There is no use of learning a programming language unless you develop a proper logic to solve problems. Simply learning the syntax of language would not serve the purpose.<\/p>\n<p>Here, we will discuss some of the most common or basic C Programs, that will help you to code better.<\/p>\n<ul>\n<li>Fibonacci series in C<\/li>\n<li>Prime numbers in C<\/li>\n<li>Palindrome in C<\/li>\n<li>Factorial in C<\/li>\n<li>Number reversal in C<\/li>\n<li>Matrix multiplication in C<\/li>\n<li>Decimal to binary conversion in C<\/li>\n<\/ul>\n<p>We will explain each code step by step for a clear understanding of how it works.<\/p>\n<h2>Basic C Programs<\/h2>\n<p>A good programmer has great command over the concepts of a language as well as the skills required to develop algorithms to solve complex problems that come through rigorous practice.<\/p>\n<p>We are going to discuss mentioned Basic C Programs to reach out to them and explore its structure &amp; syntax through an example. We will cover each and every topic related to them and will let you know about the small things related to them.<\/p>\n<p>After reading them, I am sure that your concepts for these basic C programs would be crystal clear &amp; it would not make any trouble in the future to you.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59857\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg\" alt=\"Basic C Programs\" width=\"802\" height=\"420\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg 802w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs-520x272.jpg 520w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<h3>1. Fibonacci Series in C<\/h3>\n<p>Let us begin our discussion by trying to understand what is the Fibonacci series?<\/p>\n<p>In mathematics, a Fibonacci series refers to <em>the sequence in which the next element is equal to the sum of its two preceding elements<\/em>.<\/p>\n<p>Therefore, the first two numbers in the sequence need to be specified.<\/p>\n<p>Generally, the first term is 0 and the second is 1.<\/p>\n<p>The Fibonacci series goes on like this up till n numbers:<\/p>\n<p>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584\u2026. N<\/p>\n<p><em><strong>Before discussing the example, revise the <a href=\"https:\/\/data-flair.training\/blogs\/basic-structure-of-c-program\/\">Basic Structure of C Program<\/a><\/strong><\/em><\/p>\n<h4>Example of\u00a0Fibonacci Series in C<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint number_of_terms, iteration;\r\nint term1 = 0, term2 = 1, next_term;\r\n\r\nprintf(\"Enter the number of terms till you want to display the numbers in the Fibonacci series: \");\r\nscanf(\"%d\", &amp;number_of_terms);\r\n\r\nprintf(\"The Fibonacci series up till %d terms is: \",number_of_terms);\r\n\r\nfor (iteration = 1; iteration &lt;= number_of_terms; iteration++)\r\n{\r\nprintf(\"%d \", term1);\r\nnext_term = term1 + term2; \/\/ Next term is the sum of previous terms\r\nterm1 = term2;\r\nterm2 = next_term;\r\n}\r\nreturn 0;\r\n}\r\n<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59832\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C.jpg\" alt=\"Example of\u00a0Fibonacci Series in C\" width=\"1299\" height=\"699\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C-150x81.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C-300x161.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C-768x413.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C-1024x551.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Fibonacci-Series-in-C-520x280.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59833\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C.jpg\" alt=\"Output of Fibonacci Series in C\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Fibonacci-Series-in-C-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong><span style=\"font-size: 1rem\">Elucidation<\/span><\/strong><\/p>\n<p><strong>Declaration:<\/strong> We declare the variable \u2018number_of_terms\u2019 to find the terms till which the series is to be displayed, the variable \u2018iteration\u2019 to traverse the for loop. Then, we initialize the first and second term as 0 and 1 respectively are their values are fixed.<\/p>\n<p><strong>Input:<\/strong> We take the input of the number of terms to be entered by the user till which he wishes to display the Fibonacci series.<\/p>\n<p><strong>Logic:\u00a0<\/strong>We initialize the variable \u2018iteration\u2019 to 1. We make the loop run till the number of terms in the series and print the first term and second term.<\/p>\n<ul>\n<li>Now, our task is to find the sum of both the terms, that is, 0 and 1 to obtain the next term.<\/li>\n<li>When the loop runs for the second time, we store the result obtained, that is, 2, to the second term and the original second term to the original first term.<\/li>\n<li>The same process is repeated until the variable \u2018iteration\u2019 becomes equal to the number of terms.<\/li>\n<\/ul>\n<p><em><strong>Do you know how to declare<a href=\"https:\/\/data-flair.training\/blogs\/variables-in-c\/\"> Variables in C<\/a>?<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fibonacci-Series-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59795\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fibonacci-Series-in-C.jpg\" alt=\"Fibonacci Series in C\" width=\"350\" height=\"500\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fibonacci-Series-in-C.jpg 350w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fibonacci-Series-in-C-105x150.jpg 105w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fibonacci-Series-in-C-210x300.jpg 210w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p><strong>Here is a code in C to display the Fibonacci series up till a given number:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint term1 = 0, term2 = 1, next_term = 0, limit;\r\n\r\nprintf(\"Enter a number till which you want to display the Fibonacci series: \");\r\nscanf(\"%d\", &amp;limit);\r\n\r\nprintf(\"The Fibonacci series till %d is: %d, %d, \",limit, term1, term2); \/\/ term1 = 0 and term2 = 1\r\n\r\nnext_term = term1 + term2;\r\nwhile(next_term &lt;= limit)\r\n{\r\nprintf(\"%d \",next_term);\r\nterm1 = term2;\r\nterm2 = next_term;\r\nnext_term = term1 + term2;\r\n}\r\nreturn 0;\r\n}<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59834\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series.jpg\" alt=\"C Fibonacci Series Example\" width=\"1299\" height=\"699\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-150x81.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-300x161.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-768x413.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-1024x551.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-520x280.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59835\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output.jpg\" alt=\"C Fibonacci Series Output\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/C-Fibonacci-Series-Output-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Elucidation<\/strong><\/p>\n<p><strong>Declaration:<\/strong> We declare a variable limit to find the number till which the Fibonacci series is to be displayed. We initialize the variables \u2018term1\u2019 and \u2018term2\u2019 to 0 and 1 respectively as their values are constant. We initialize next_term to 0 for the traversal of the while loop.<\/p>\n<p><strong>Input:<\/strong> We take the input of the limit by the user till which he wishes to display the Fibonacci series.<\/p>\n<p><strong>Logic:\u00a0<\/strong>We store the sum of the first two terms, that is, 0 and 1 in the variable \u2018next_term\u2019.<\/p>\n<ul>\n<li>The while loop runs till the next term would be equal to the limit entered by the user.<\/li>\n<li>At the first iteration, the value of the second term is stored in the first term. Then, the value of the next term is stored in the second term. Finally, we add the newly obtained terms to the next_term.<\/li>\n<li>This process keeps on repeating itself till all the numbers are displayed less than the limit entered by the user.<\/li>\n<\/ul>\n<h3>2. Prime Numbers in C<\/h3>\n<p>Before we begin our discussion on prime numbers, it is important to understand conditional statements and <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/operators-in-c\/\">operators in C<\/a><\/strong><\/em>.<\/p>\n<p>A prime number is nothing but a natural number (1, 2, 3, 4\u2026..) with its only factors as 1 and the number itself with the exclusion of 1.<\/p>\n<h4>Example of\u00a0Prime Numbers in C<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint number, iteration;\r\nint flag = 0; \/\/ Initialize\r\n\r\nprintf(\"Enter a positive number to check if it is prime or not \");\r\nscanf(\"%d\", &amp;number);\r\n\r\nfor(iteration = 2; iteration &lt;= number\/2; iteration++)\r\n{\r\nif(number%iteration == 0) \/\/ Condition for a non-prime number\r\n{\r\nflag = 1; \/\/ To indicate that the number is non-prime\r\nbreak;\r\n}\r\n}\r\n\r\nif (number == 1)\r\n{\r\nprintf(\"1 is not a prime number.\\n\");\r\n}\r\nelse\r\n{\r\nif (flag == 0)\r\nprintf(\"%d is a prime number.\\n\", number);\r\nelse\r\nprintf(\"%d is not a prime number.\\n\", number);\r\n}\r\n\r\nreturn 0;\r\n}\r\n\r\n<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59839\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C.jpg\" alt=\"Example of Prime number in C\" width=\"1299\" height=\"699\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C-150x81.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C-300x161.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C-768x413.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C-1024x551.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Prime-number-in-C-520x280.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59840\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C.jpg\" alt=\"Output of Prime number in C\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Prime-number-in-C-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Elucidation<\/strong><\/p>\n<p><strong>Declaration:<\/strong> We declare the variable \u2018number\u2019 to check if it is prime or not and \u2018iteration\u2019 to traverse the for loop. We initialize the variable \u2018flag\u2019 to 0 used for indication of the prime or non-prime number<\/p>\n<p><strong>Input:<\/strong> We take the input of the number entered by the user to check if it is prime or not.<\/p>\n<p><strong>Logic:\u00a0<\/strong>Our main aim is to check if there is any factor of the number other than 1 or the number itself in the range (1, number). If there exists a number such that it divides the number, then the number is non-prime.<\/p>\n<ul>\n<li>After checking the condition of a non-prime number, we can use the break statement to exit out of that condition. The else condition would print the number that is not non-prime. Therefore, we get a prime number.<\/li>\n<\/ul>\n<p><strong>Explanation Through Dry Run:<\/strong><\/p>\n<p>Consider the value of the variable number = 19.<\/p>\n<p>Since iteration starts from 2 till the integral division of 19\/2 = 9, therefore:<\/p>\n<p>Iteration would take the values: 2, 3, 4, 5, 6, 7, 8 and 9.<\/p>\n<p>Checking the condition if number % iteration is divisible with each other, that is,<\/p>\n<p>19 % 2 \u2260 0<br \/>\n19 % 3 \u2260 0<br \/>\n19 % 4 \u2260 0<br \/>\n19 % 5 \u2260 0<br \/>\n19 % 6 \u2260 0<br \/>\n19 % 7 \u2260 0<br \/>\n19 % 8 \u2260 0<br \/>\n19 % 9 \u2260 0<\/p>\n<p>Since these conditions are not satisfied, we conclude the number 19 is not non-prime which means that it is a prime number.<\/p>\n<p>In order to come out of the if-condition, we use the break statement. Therefore, the flow of control is transferred to the else condition that indicates that the number 19 is prime.<\/p>\n<p><strong>Here is a program in C that helps you find a prime number in a given range:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint lower_limit, upper_limit, iteration;\r\nint flag; \/\/ A variable flag to indicate if the number is prime or not\r\nprintf(\"Enter the range:\\n\");\r\nprintf(\"Lower limit: \");\r\nscanf(\"%d\",&amp;lower_limit);\r\nprintf(\"Upper limit: \");\r\nscanf(\"%d\",&amp;upper_limit);\r\n\r\nprintf(\"The prime numbers in the range (%d,%d) are:\\n\", lower_limit, upper_limit);\r\n\r\nwhile (lower_limit &lt; upper_limit)\r\n{\r\nflag = 0;\r\nfor(iteration = 2; iteration &lt;= lower_limit\/2; iteration++)\r\n{\r\nif(lower_limit % iteration == 0)\r\n{\r\nflag = 1; \/\/ Condition for non-prime number\r\nbreak;\r\n}\r\n}\r\nif (flag == 0)\r\n{\r\nprintf(\"%d \", lower_limit);\r\n}\r\nlower_limit++;\r\n}\r\nreturn 0;\r\n}\r\n<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59841\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C.jpg\" alt=\"C Prime Number Example\" width=\"1299\" height=\"682\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C-768x403.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C-1024x538.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Fine-Prime-number-in-C-520x273.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59842\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number.jpg\" alt=\"Output of C prime Number\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-prime-Number-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong><span style=\"font-size: 1rem\">Elucidation<\/span><\/strong><\/p>\n<p><strong>Declaration:<\/strong> We declare the variables \u2018lower_limit\u2019 and \u2018upper_limit \u2019to specify the range between which we are supposed to find all the prime numbers.<\/p>\n<p><strong>Input:<\/strong> We take the input of the lower limit and upper limit from the user to display the prime numbers within that range.<\/p>\n<p><strong>Logic:\u00a0<\/strong>Our main aim is to check if there is any factor of the numbers other than 1 or the number itself in the range (lower_limit, upper_limit). If there exists a number such that it divides the number, then the number is non-prime.<\/p>\n<ul>\n<li>The variable \u2018flag\u2019 indicates if the number is prime or not.<\/li>\n<li>After checking the condition of a non-prime number, we can use the break statement to exit out of that condition. The else condition would print the number that is not non-prime. Therefore, we get a prime number.<\/li>\n<li>After incrementing the value of the lower limit, the loop continues to run till the lower limit continues to be less than the upper limit.<\/li>\n<\/ul>\n<h3>3. Palindrome in C<\/h3>\n<p>Before we begin our discussion on Palindromes, it is important to understand iteration, conditional statements, operators, and\u00a0<em><strong><a href=\"https:\/\/data-flair.training\/blogs\/strings-in-c-programming\/\">strings in C<\/a><\/strong><\/em>.<\/p>\n<p>A palindrome in C is nothing but either a number, word or phrase that is read in a similar fashion forward as well as backward.<\/p>\n<p>For instance,<\/p>\n<ul>\n<li>The number 181 is a palindrome.<\/li>\n<li>The word \u201channah\u201d is a palindrome.<\/li>\n<li>The phrase \u201cmadam or nurses run\u201d is a palindrome.<\/li>\n<\/ul>\n<p>We will discuss 2 Basic C programs based on Palindromes:<\/p>\n<ol>\n<li>To check if the given number is a palindrome or not.<\/li>\n<li>To check if the given word is a palindrome or not.<\/li>\n<\/ol>\n<h4>Example of\u00a0Palindrome Series in C<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint number, number_reverse = 0, remainder, original_number;\r\n\r\nprintf(\"Enter an integer: \");\r\nscanf(\"%d\", &amp;number);\r\n\r\noriginal_number = number; \/\/ Storing the value of the number into a variable original_number\r\n\r\n\/* Reversing the number *\/\r\nwhile( number!=0 )\r\n{\r\nremainder = number % 10;\r\nnumber_reverse = number_reverse * 10 + remainder;\r\nnumber \/= 10;\r\n}\r\n\/\/ To check if the original number and the reversed number are equal or not\r\nif (original_number == number_reverse)\r\nprintf(\"%d is a palindrome.\\n\", original_number);\r\nelse\r\nprintf(\"%d is not a palindrome.\\n\", original_number);\r\nreturn 0;\r\n}<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59843\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C.jpg\" alt=\"Palindrome in C with Example\" width=\"1299\" height=\"682\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C-768x403.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C-1024x538.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Palindrome-in-C-520x273.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome-.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59844\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome-.jpg\" alt=\"Output of C Palindrome\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome-.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome--150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome--300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome--768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome--1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-C-Palindrome--520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Elucidation<\/strong><\/p>\n<p><strong>Declaration:<\/strong> We declare the variable \u2018number\u2019 to store the value entered by the user to check if it is a palindrome or not, the variable \u2018remainder\u2019 to find the remainder when the integral division of that number is performed with 10, and the variable \u2018original_number\u2019 to store the value of the number entered by the user temporarily. We initialize the variable \u2018number_reverse to 0 for loop traversal.<\/p>\n<p><strong>Input:<\/strong> We take the input of the number to check if it is a palindrome or not from the user in the variable \u2018number\u2019.<\/p>\n<p><strong>Logic: <\/strong>The while loop runs till the number entered by the user becomes 0<\/p>\n<ul>\n<li>A set of conditions is given to extract the reversed number from the number entered by the user.<\/li>\n<li>If the value of the variable \u2018number_reverse\u2019 matches to that of the original number, then the given number enter by the user is a palindrome.<\/li>\n<\/ul>\n<h3>Explanation through Dry Run:<\/h3>\n<p>Consider the value of the number = 181<\/p>\n<p>The while loop will run for 3 times, given as:<\/p>\n<p><strong>1. First iteration, number = 181<\/strong><\/p>\n<p>remainder = 181 % 10 = 1<br \/>\nnumber_reverse = ( 0 * 10 ) + 1 = 1<br \/>\nnumber = 181 \/ 10 = 18<\/p>\n<p><strong>2. Second iteration, number = 18<\/strong><\/p>\n<p>remainder = 18 % 10 = 8<br \/>\nnumber_reverse = ( 1 * 10 ) + 8 = 18<br \/>\nnumber = 18 \/ 10 = 1<\/p>\n<p><strong>3. Third iteration, number = 1<\/strong><\/p>\n<p>remainder = 1 % 10 = 1<br \/>\nnumber_reverse = ( 18 * 10 ) + 1 = 181<br \/>\nnumber = 1 \/ 10 = 0<\/p>\n<p>The loop will no longer run as the base condition no longer continues to be satisfied as the number reached its minimum value = 0<\/p>\n<p><strong>Here is a program in C that checks if the given word entered by the user as a string if a palindrome or not:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nchar string1[30], string2[30], temp;\r\nint i,j;\r\nprintf(\"Enter the first string to check if it is a palindrome\\n\");\r\nfgets(string1,30,stdin);\r\nstrcpy(string2, string1);  \/\/ Copying the first string to the second one\r\n\/\/ Reversing the string\r\n\r\ni = 0;\r\nj = strlen(string2)-1;\r\nwhile (i &lt; j)\r\n{\r\ntemp = string2[i];\r\nstring2[i] = string2[j];\r\nstring2[j] = temp;\r\ni++;\r\nj--;\r\n}\r\nputs(string2);\r\nif (strcmp(string1, string2) == 0)  \/\/ Comparing input string with the reverse string\r\n{\r\nprintf(\"The string %s is a palindrome\\n\",string1);\r\n}\r\nelse\r\n{\r\nprintf(\"The string %s isn't a palindrome\\n\",string1);\r\n}\r\nreturn 0;\r\n}<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59846\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C.jpg\" alt=\"Example of palindrome in C\" width=\"1302\" height=\"700\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C.jpg 1302w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C-150x81.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C-300x161.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C-768x413.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C-1024x551.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-palindrome-in-C-520x280.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\/06\/Output-of-Palindrome-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59847\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C.jpg\" alt=\"Output of Palindrome in C\" width=\"1301\" height=\"685\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C.jpg 1301w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C-768x404.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C-1024x539.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Palindrome-in-C-520x274.jpg 520w\" sizes=\"auto, (max-width: 1301px) 100vw, 1301px\" \/><\/a><\/p>\n<h3>4. Factorial Program in C<\/h3>\n<p>Before we begin our discussion on how to find the factorial of a number, it is important to be thorough with Iteration, Data types, Conditional statement, and Operators in C.<\/p>\n<p>Let us try to understand what is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Factorial\">factorial<\/a>:<\/p>\n<p>The factorial of a number n is given by: 1 x 2 x 3 x 4 \u2026\u2026\u2026\u2026\u2026\u2026.. x n.<\/p>\n<p>For instance, the factorial of 5 given given by: 1 x 2 x 3 x 4 x 5 = 120.<\/p>\n<p><strong>Example of Factorial in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint number, iteration;\r\nlong factorial = 1; \/\/ initializing factorial to 1\r\n\r\nprintf(\"Enter a positive integer: \");\r\nscanf(\"%d\",&amp;number);\r\n\r\nif (number &lt; 0) \/\/ If the user enters a negative number\r\nprintf(\"The factorial of a negative number does not exist\\n\");\r\nelse\r\n{\r\nfor(iteration = 1; iteration &lt;= number; iteration++)\r\n{\r\nfactorial = factorial*iteration;\r\n}\r\nprintf(\"The factorial of %d is %lu\\n\", number, factorial);\r\n}\r\nreturn 0;\r\n}\r\n<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59848\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C.jpg\" alt=\"Example of Factorial Program in C\" width=\"1299\" height=\"682\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C-768x403.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C-1024x538.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-Factorial-Program-in-C-520x273.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59849\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C.jpg\" alt=\"Output of Factorial Program in C\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Factorial-Program-in-C-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong><span style=\"font-size: 1rem\">Elucidation<\/span><\/strong><\/p>\n<p>We can understand the working of this program with the help of a dry run:<\/p>\n<p>Consider number = 8<\/p>\n<p>For i = 1<\/p>\n<p>factorial = 1 * 1 = 1<\/p>\n<p>For i = 2<\/p>\n<p>factorial = 1* 2 = 2<\/p>\n<p>For i = 3<\/p>\n<p>factorial = 2 * 3 = 6<\/p>\n<p>For i = 4<\/p>\n<p>factorial = 6 * 4 = 24<\/p>\n<p>For i = 5<\/p>\n<p>factorial = 24 * 5 = 120<\/p>\n<p>For i = 6<\/p>\n<p>factorial = 120 * 6 = 720<\/p>\n<p>For i = 7<br \/>\nfactorial = 720 * 7 = 5040<\/p>\n<p>For i = 8<\/p>\n<p>factorial = 5040 * 8 = 40320<\/p>\n<p>Hence, we obtain the value of 8! = 40320<\/p>\n<p><span style=\"font-size: 1rem\"><strong>Key takeaway:<\/strong> You can even find the factorial of a number using<em> <strong><a href=\"https:\/\/data-flair.training\/blogs\/recursion-in-c\/\">recursion in C<\/a><\/strong><\/em>.<\/span><\/p>\n<h3>5. Number Reversal in C<\/h3>\n<p>Before we begin our discussion on number reversal, it is important to understand Operators in C and Iteration in C.<\/p>\n<p>The purpose of this program is to reverse a number.<\/p>\n<p>For instance,<\/p>\n<p>The reversal of the number 67193 is 39176<\/p>\n<p><strong>Example of Number Reversal in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint number, number_reverse, remainder;\r\nnumber_reverse = 0; \/\/ initializing number_reverse to 0\r\n\r\nprintf(\"Enter a number in the form of an integer: \");\r\nscanf(\"%d\", &amp;number);\r\n\r\nwhile(number != 0)\r\n{\r\nremainder = number%10;\r\nnumber_reverse = number_reverse*10 + remainder;\r\nnumber = number\/10;\r\n}\r\nprintf(\"The reversed number is: %d\\n\", number_reverse);\r\nreturn 0;\r\n}<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59852\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example.jpg\" alt=\"Number Reversal in C with Example\" width=\"1299\" height=\"682\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example-768x403.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example-1024x538.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Number-Reversal-in-C-with-Example-520x273.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59853\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C.jpg\" alt=\"Output of Number Reversal in C\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Number-Reversal-in-C-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Elucidation<\/strong><\/p>\n<p>The same concept has been applied to the palindrome problem.<\/p>\n<h3>6. Matrix Manipulation in C<\/h3>\n<p>Before we begin our discussion on matrix multiplication, it is important to understand<strong><a href=\"https:\/\/data-flair.training\/blogs\/arrays-in-c\/\"> Arrays<\/a> and<\/strong> <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/multi-dimensional-arrays-in-c\/\">Multidimensional arrays in C<\/a><\/strong><\/em>.<\/p>\n<p>Matrix Multiplication is one of the popular basic of C programs, let us begin our discussion by trying to understand what a matrix is.<\/p>\n<p>In mathematics, a matrix is referred to as a rectangular array of elements used to represent numbers, symbols, or expressions in the form of horizontal rows and vertical columns.<\/p>\n<p><strong>The general form of a m x n matrix is:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-format-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59803\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-format-in-C.jpg\" alt=\"Matrix format in C\" width=\"300\" height=\"200\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-format-in-C.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-format-in-C-150x100.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-format-in-C-272x182.jpg 272w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>This is an example of a 4 x 3 matrix:<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59801\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-in-C.jpg\" alt=\"Matrix in C\" width=\"300\" height=\"200\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-in-C.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-in-C-150x100.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Matrix-in-C-272x182.jpg 272w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><strong>This is how you can visualize a matrix, say A[m][n] with m number of rows and n number of columns:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-matrix-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59804\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-matrix-in-C.jpg\" alt=\"Example of Matrix of C\" width=\"700\" height=\"300\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-matrix-in-C.jpg 700w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-matrix-in-C-150x64.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-matrix-in-C-300x129.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Example-of-matrix-in-C-520x223.jpg 520w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n<p><strong>It is important to note that not every matrix can be multiplied with another matrix.<\/strong><\/p>\n<p><strong>Condition for multiplication of 2 matrices:<\/strong><\/p>\n<p>Two matrices can be multiplied only when the number of columns of the first matrix is equal to the number of rows in the second matrix.<\/p>\n<p><strong>How to multiply 2 matrices:<\/strong><\/p>\n<p>Each element of the resultant matrix is obtained by multiplying the elements of each row of the first matrix with its corresponding elements of each column of the second matrix and adding them together.<\/p>\n<p><strong>Example of Matrix Multiplication in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint row1, column1, row2, column2, sum = 0;\r\nint iteration1, iteration2, iteration3;\r\nint matrix1[10][10], matrix2[10][10], product[10][10];\r\n\r\nprintf(\"Enter the number of rows and columns of first matrix: \");\r\nscanf(\"%d%d\", &amp;row1, &amp;column1);\r\n\r\nprintf(\"Enter the elements of first matrix\\n\\n\");\r\n\r\nfor (iteration1 = 0; iteration1 &lt; row1; iteration1++)\r\n{\r\nfor (iteration2 = 0; iteration2 &lt; column1; iteration2++)\r\n{\r\nscanf(\"%d\", &amp;matrix1[iteration1][iteration2]);\r\n}\r\n}\r\n\r\nprintf(\"Enter the number of rows and columns of second matrix: \");\r\nscanf(\"%d%d\", &amp;row2, &amp;column2);\r\n\r\nif (column1 != row2)\r\n{\r\nprintf(\"The matrices can't be multiplied.\\n\\n\");\r\n}\r\nelse\r\n{\r\nprintf(\"Enter the elements of second matrix\\n\\n\");\r\n\r\nfor (iteration1 = 0; iteration1 &lt; row1; iteration1++)\r\n{\r\nfor (iteration2 = 0; iteration2 &lt; column2; iteration2++)\r\n{\r\nscanf(\"%d\", &amp;matrix2[iteration1][iteration2]);\r\n}\r\n}\r\nfor (iteration1 = 0; iteration1 &lt; row1; iteration1++)\r\n{\r\nfor (iteration2 = 0; iteration2 &lt; column2; iteration2++)\r\n{\r\nfor (iteration3 = 0; iteration3 &lt; row2; iteration3++)\r\n{\r\nsum = sum + matrix1[iteration1][iteration3]*matrix2[iteration3][iteration2];\r\n}\r\n\r\nproduct[iteration1][iteration2] = sum;\r\nsum = 0;\r\n}\r\n}\r\n\r\nprintf(\"The product of the matrices is:\\n\\n\");\r\n\r\nfor (iteration1 = 0; iteration1 &lt; row1; iteration1++)\r\n{\r\nfor (iteration2 = 0; iteration2 &lt; column2; iteration2++)\r\nprintf(\"%d\\t\", product[iteration1][iteration2]);\r\nprintf(\"\\n\");\r\n}\r\n}\r\nreturn 0;\r\n}<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59854\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C.jpg\" alt=\"Output of Matrix Multiplication in C\" width=\"1300\" height=\"675\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C.jpg 1300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C-150x78.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C-300x156.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C-768x399.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C-1024x532.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Matrix-Multiplication-in-C-520x270.jpg 520w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/p>\n<h3>7. Convert Decimal to Binary Number in C<\/h3>\n<p>Before we begin our discussion on decimal to binary conversions, it is important to understand Operators in C.<\/p>\n<p><strong>Here is a code in C that illustrates how to convert a number in a decimal number system to binary number system:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#include &lt;stdio.h&gt;\r\n#include &lt;math.h&gt;\r\nlong decimal_to_binary(int decimal_number)\r\n{\r\nlong binary_number = 0;\r\nint remainder, iteration = 1;\r\n\r\nwhile (decimal_number != 0)\r\n{\r\nremainder = decimal_number%2;\r\ndecimal_number = decimal_number\/ 2;\r\nbinary_number = binary_number+ remainder*iteration;\r\niteration = iteration*10;\r\n}\r\nreturn binary_number;\r\n}\r\n\r\nint main()\r\n{\r\n\r\nprintf(\"Welcome to DataFlair tutorials!\\n\\n\");\r\n\r\nint decimal_number;\r\nprintf(\"Enter a positive integer in decimal system: \");\r\nscanf(\"%d\", &amp;decimal_number);\r\nprintf(\"The number %d in decimal system to binary is %ld\\n\", decimal_number, decimal_to_binary(decimal_number));\r\nreturn 0;\r\n}<\/pre>\n<p><strong>Code-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59855\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C.jpg\" alt=\"Convert Decimal to Binary Number in C\" width=\"1299\" height=\"682\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C-300x158.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C-768x403.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C-1024x538.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Convert-Decimal-to-Binary-Number-in-C-520x273.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-59856\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C.jpg\" alt=\"Convert Decimal to Binary Number in C\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Output-of-Convert-Decimal-to-Binary-Number-in-C-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>In this tutorial, we discussed the basic C programs that helped us to develop a deep understanding of the logical statements and algorithms involved while solving a problem. After discussing all these seven problems in detail, you are ready to master a couple of fundamental problems that you might encounter in the long run. Good luck on your programming journey!<\/p>\n<p><em><strong>Next step &#8211; <a href=\"https:\/\/data-flair.training\/blogs\/functions-in-c\/\">Functions in C Language<\/a><\/strong><\/em><\/p>\n<p>If you have any queries regarding the working of any of these Basic of C programs, feel free to share it in the comment section below.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1501,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Factorial&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251208023612\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Factorial&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 09:31:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-13 21:40:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-25 01:16:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-01 13:39:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-06 12:26:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-13 14:18:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-22 08:23:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-05 09:24:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-09 07:06:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-22 18:22:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-26 02:52:35&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-02 07:19:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 01:19:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-04 18:22:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-08 05:59:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-13 14:26:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-16 14:51:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-20 14:47:14&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-25 03:25:42&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-04 14:44:51&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-04 14:44:51&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If the roots of a tree are not strong, it would not be able to support the tree. Similarly, if you are not aware of some of the basic C Programs and you wish&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":59857,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19488],"tags":[19577,20198,20190,20191,20195,20192,20197,20196,20194,20193],"class_list":["post-59783","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-basic-c-program","tag-c-programming-examples","tag-c-programs","tag-example-of-c","tag-factorial-in-c","tag-fibonacci-series-in-c","tag-matrix-multiplication-in-c","tag-number-reversal-in-c","tag-palindrome-in-c","tag-prime-numbers-in-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>7 Basic C Programs that will help you to rise from Noob to Pro - DataFlair<\/title>\n<meta name=\"description\" content=\"Basic C Programs Contains - Fibonacci series, Prime numbers, Palindrome, Factorial, Number reversal, Matrix multiplication, Decimal to binary conversion with examples\" \/>\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\/basic-c-programs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"7 Basic C Programs that will help you to rise from Noob to Pro - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Basic C Programs Contains - Fibonacci series, Prime numbers, Palindrome, Factorial, Number reversal, Matrix multiplication, Decimal to binary conversion with examples\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/basic-c-programs\/\" \/>\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-06-18T11:50:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-24T05:22:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.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=\"15 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"7 Basic C Programs that will help you to rise from Noob to Pro - DataFlair","description":"Basic C Programs Contains - Fibonacci series, Prime numbers, Palindrome, Factorial, Number reversal, Matrix multiplication, Decimal to binary conversion with examples","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\/basic-c-programs\/","og_locale":"en_US","og_type":"article","og_title":"7 Basic C Programs that will help you to rise from Noob to Pro - DataFlair","og_description":"Basic C Programs Contains - Fibonacci series, Prime numbers, Palindrome, Factorial, Number reversal, Matrix multiplication, Decimal to binary conversion with examples","og_url":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-06-18T11:50:19+00:00","article_modified_time":"2019-06-24T05:22:42+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.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":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"7 Basic C Programs that will help you to rise from Noob to Pro","datePublished":"2019-06-18T11:50:19+00:00","dateModified":"2019-06-24T05:22:42+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/"},"wordCount":2071,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg","keywords":["Basic C Program","c programming examples","C programs","Example of C","Factorial in C","Fibonacci series in C","Matrix multiplication in C","Number reversal in C","Palindrome in C","Prime numbers in C"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/basic-c-programs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/","url":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/","name":"7 Basic C Programs that will help you to rise from Noob to Pro - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg","datePublished":"2019-06-18T11:50:19+00:00","dateModified":"2019-06-24T05:22:42+00:00","description":"Basic C Programs Contains - Fibonacci series, Prime numbers, Palindrome, Factorial, Number reversal, Matrix multiplication, Decimal to binary conversion with examples","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/basic-c-programs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/06\/Basic-C-Programs.jpg","width":802,"height":420,"caption":"Basic C Programs"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/basic-c-programs\/#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":"7 Basic C Programs that will help you to rise from Noob to Pro"}]},{"@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\/59783","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=59783"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/59783\/revisions"}],"predecessor-version":[{"id":60368,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/59783\/revisions\/60368"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/59857"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=59783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=59783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=59783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}