<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mayank</title>
    <description>The latest articles on DEV Community by Mayank (@low-level-systems).</description>
    <link>https://dev.to/low-level-systems</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3976344%2Fd5a61f88-dee6-438f-b8af-98c2410b4fa7.png</url>
      <title>DEV Community: Mayank</title>
      <link>https://dev.to/low-level-systems</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/low-level-systems"/>
    <language>en</language>
    <item>
      <title>Day-04 : Understanding int in C: Binary, Ranges, and What Happens When You Overflow</title>
      <dc:creator>Mayank</dc:creator>
      <pubDate>Fri, 12 Jun 2026 05:14:29 +0000</pubDate>
      <link>https://dev.to/low-level-systems/day-04-understanding-int-in-c-binary-ranges-and-what-happens-when-you-overflow-3ofm</link>
      <guid>https://dev.to/low-level-systems/day-04-understanding-int-in-c-binary-ranges-and-what-happens-when-you-overflow-3ofm</guid>
      <description>&lt;h2&gt;
  
  
  What I Learned Today (Week-01/Day-04)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Fundamental Data Types -&amp;gt; int&lt;/li&gt;
&lt;li&gt;Decimal and Binary Number System&lt;/li&gt;
&lt;li&gt;Types of int and their ranges&lt;/li&gt;
&lt;li&gt;Edge cases in the range of data types&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Data types are the fundamentals of any programming language. Data types define the type of data that will be stored in a variable and the size of the variable — this can depend on one's system, but generally it is the same for everyone.&lt;/p&gt;

&lt;p&gt;As we have discussed, the CPU understands only 0s and 1s. These are binary numbers with &lt;strong&gt;base 2&lt;/strong&gt;. So, the data that is read or written by the CPU has to be in binary too.&lt;/p&gt;

&lt;p&gt;Before starting, let's see what the size of int is on our system. Run the following command on your system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Size of Integer(int) : %d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output would be this for my system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meaning, on my system, int takes 4 bytes of space irrespective of how small or how large an integer we provide to our code. &lt;em&gt;(Note: There is a limit to this, and we will discuss it further.)&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  How Numbers Are Stored: Decimal vs Binary
&lt;/h3&gt;

&lt;p&gt;So, we know &lt;strong&gt;int&lt;/strong&gt; takes 4 bytes of space.&lt;/p&gt;

&lt;p&gt;But what does that mean?&lt;/p&gt;

&lt;p&gt;Let's revisit the decimal number system we use every day. The decimal number system is a base-10 number system using digits from 0 to 9. So, your question should be: if we can only use 0 to 9, how can we represent a number like 1450?&lt;/p&gt;

&lt;p&gt;It's simple — we multiply each digit by its respective place value. From right to left, to represent a four-digit number we do: &lt;code&gt;(digit × 10³) + (digit × 10²) + (digit × 10¹) + (digit × 10⁰)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So 1450: &lt;code&gt;(1 × 10³) + (4 × 10²) + (5 × 10¹) + (0 × 10⁰)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;= 1000 + 400 + 50 + 0 = 1450&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I hope you know addition 😀&lt;/p&gt;

&lt;p&gt;In the decimal number system, numbers range from 0 to 9. We can't use a digit outside this range — it's invalid.&lt;/p&gt;

&lt;p&gt;Similarly, in the binary number system we have a range of only 0 and 1, and luckily the CPU understands this rather than '1450'. A valid question here is: if the CPU understands only 0s and 1s, how can we see different numbers on our screen? It's simple — counting numbers like (0, 1, 2, 3, ...10, 11, 12...100, 101, 102) can be represented in any number system, be it binary, decimal, or octal. The only thing that changes is how we use digits within that number system. In the case of binary, we do this:&lt;/p&gt;

&lt;p&gt;Take a random 4-digit binary number: &lt;code&gt;1100&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Similarly, we replace &lt;code&gt;10^place_value&lt;/code&gt; with &lt;code&gt;2^place_value&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;1100 : (1 × 2³) + (1 × 2²) + (0 × 2¹) + (0 × 2⁰)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;= 8 + 4 + 0 + 0 =&lt;/code&gt;&lt;strong&gt;12&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is how we represent the number 12 in binary as &lt;code&gt;1100&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You may have heard storage terms like Gigabytes, Kilobytes, and Megabytes.&lt;/p&gt;

&lt;p&gt;These are nothing but collections of 0s and 1s.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When we use either a 0 or a 1, we call it a &lt;strong&gt;bit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When we group together 8 bits, we call it a &lt;strong&gt;byte&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When we group 1024 bytes, we call it a &lt;strong&gt;Kilobyte&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;1024 Kilobytes becomes a &lt;strong&gt;Megabyte&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Remember: the int data type takes up 4 bytes.&lt;/em&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Range of int
&lt;/h3&gt;

&lt;p&gt;Now we know how much space int takes and how 0s and 1s map to numbers like 12.&lt;/p&gt;

&lt;p&gt;We can now calculate the range of numbers our int data type can hold. &lt;em&gt;(Note: No data type can store infinite numbers.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We know from our example that &lt;code&gt;1100 → 12&lt;/code&gt;. Let's explore all combinations for the same number of digits.&lt;/p&gt;

&lt;p&gt;With 4 digits and 2 possible values per digit, here are all the results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0000 : 0&lt;/li&gt;
&lt;li&gt;0001 : 1&lt;/li&gt;
&lt;li&gt;0010 : 2&lt;/li&gt;
&lt;li&gt;0011 : 3&lt;/li&gt;
&lt;li&gt;0100 : 4&lt;/li&gt;
&lt;li&gt;0101 : 5&lt;/li&gt;
&lt;li&gt;0110 : 6&lt;/li&gt;
&lt;li&gt;0111 : 7&lt;/li&gt;
&lt;li&gt;1000 : 8&lt;/li&gt;
&lt;li&gt;1001 : 9&lt;/li&gt;
&lt;li&gt;1010 : 10&lt;/li&gt;
&lt;li&gt;1011 : 11&lt;/li&gt;
&lt;li&gt;1100 : 12&lt;/li&gt;
&lt;li&gt;1101 : 13&lt;/li&gt;
&lt;li&gt;1110 : 14&lt;/li&gt;
&lt;li&gt;1111 : 15&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So for a 4-bit binary number, the range is 0 to 15. To avoid writing out all combinations every time, we can use the formula &lt;strong&gt;(2ⁿ - 1)&lt;/strong&gt; to find the maximum value, where &lt;strong&gt;n&lt;/strong&gt; is the number of bits.&lt;/p&gt;

&lt;p&gt;For a 4-byte integer, the number of bits is &lt;code&gt;4 × 8 = 32&lt;/code&gt; bits: &lt;code&gt;(2³² - 1) = 4294967295&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the range of numbers we can store using int is &lt;strong&gt;0 to 4294967295&lt;/strong&gt;.&lt;/p&gt;


&lt;h3&gt;
  
  
  Types of Integer Data Types
&lt;/h3&gt;

&lt;p&gt;There are different integer data types available in C based on our requirements. Also note that previously we used unsigned int, which only holds positive integers. We will discuss both unsigned and signed data types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signed vs Unsigned data types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The only difference is that signed data types can also hold negative integers, while the total count of representable integers remains the same relative to the size of the data type. Unsigned data types can only hold positive integers.&lt;/p&gt;

&lt;p&gt;To get the range of a signed data type, we use this formula: &lt;strong&gt;-(2^(n-1)) to (2^(n-1) - 1)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;short int&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sizeof(short int)&lt;/code&gt; : 2 bytes&lt;/li&gt;
&lt;li&gt;Range of signed short int : -32768 to 32767&lt;/li&gt;
&lt;li&gt;Range of unsigned short int : 0 to 65535&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;int&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sizeof(int)&lt;/code&gt; : 4 bytes&lt;/li&gt;
&lt;li&gt;Range of signed int : -2147483648 to 2147483647&lt;/li&gt;
&lt;li&gt;Range of unsigned int : 0 to 4294967295&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;long int&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sizeof(long int)&lt;/code&gt; : 8 bytes&lt;/li&gt;
&lt;li&gt;Range of signed long int : -9223372036854775808 to 9223372036854775807&lt;/li&gt;
&lt;li&gt;Range of unsigned long int : 0 to 18446744073709551615&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;code&gt;sizeof(short int) &amp;lt; sizeof(int) &amp;lt; sizeof(long int)&lt;/code&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  What Happens When We Enter Integers Greater Than the Range?
&lt;/h3&gt;

&lt;p&gt;Let's say we have a 3-bit data type. The range will be 0 to 7, consisting of 8 integers.&lt;br&gt;
So we can represent: 0 to 7. But what will happen if we try to store the number 8 or higher?&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;2³&lt;/th&gt;
&lt;th&gt;2²&lt;/th&gt;
&lt;th&gt;2¹&lt;/th&gt;
&lt;th&gt;2⁰&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When our data type is 3 bits wide, our range is 0 to 7 only. When we give 8 (&lt;code&gt;1000&lt;/code&gt;) as input, it has 4 digits — but our data type reads only 3 digits from right to left: 1*&lt;em&gt;000&lt;/em&gt;*, so the output will be 0.&lt;/p&gt;

&lt;p&gt;The pattern here is &lt;strong&gt;MOD 2ⁿ&lt;/strong&gt;: &lt;code&gt;8 MOD 8 = 0&lt;/code&gt;, &lt;code&gt;9 MOD 8 = 1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Even if we give 9 as input, we will receive 1 as output.&lt;/p&gt;

&lt;p&gt;Here is an example with unsigned int:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4294967295&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4294967296&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Here are the results =&amp;gt; &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;var1 : %u&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;var2 : %u&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;var2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more, check the GitHub link below — I have the code for signed int there too.&lt;/p&gt;

&lt;p&gt;Also, think of a clock: after the hour hand hits 12, 1 repeats itself. Similarly here, from 0 to 4294967295 it forms a circle — when we try to access something out of bounds, the integers wrap around and repeat. This is just an analogy for intuition; the actual mechanism works as shown in the table above.&lt;/p&gt;

&lt;p&gt;Today we covered how integers are stored as binary, how to calculate their range, and what overflow actually looks like under the hood. Next up: floating-point numbers, where things get even more interesting.&lt;/p&gt;

&lt;p&gt;Want to run these examples yourself? Find all the code here : &lt;a href="https://github.com/mayank2patel/My_C-DS_Learning-Project/tree/main/week-01/day-04" rel="noopener noreferrer"&gt;https://github.com/mayank2patel/My_C-DS_Learning-Project/tree/main/week-01/day-04&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>c</category>
      <category>computerscience</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Day-03 : Variable and printf function</title>
      <dc:creator>Mayank</dc:creator>
      <pubDate>Thu, 11 Jun 2026 03:00:51 +0000</pubDate>
      <link>https://dev.to/low-level-systems/day-03-variable-and-printf-function-4270</link>
      <guid>https://dev.to/low-level-systems/day-03-variable-and-printf-function-4270</guid>
      <description>&lt;h2&gt;
  
  
  What I learned Today [Week-01/day-03]
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Variable Declaration and Initialization&lt;/li&gt;
&lt;li&gt;Printing sequence of characters&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Variable Declaration and Initialization
&lt;/h3&gt;

&lt;p&gt;In C, unlike dynamically typed languages like Python or JavaScript, we have to explicitly declare the variable before using it. In Python you can just write x = 3 and Python figures out the type on its own at runtime. In C, you have to tell the compiler upfront — "hey, this variable is going to hold an integer" — and only then can you use it.&lt;/p&gt;

&lt;p&gt;Declaration means assigining properties to the variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type of the variable&lt;/li&gt;
&lt;li&gt;Name of the variable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Here, int is the Data type defining the type of data that variable will store. It also assigns the size of the varibale that it will hold.
Then, var is the name of the variable pointing to the memory where will the values be stored. Without Initialization the variables will store garbage values.
*/&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Here, when we assign 3 to the var. We got Initialization of the variable and can be used to perform different operation while holding that value.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Printing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Neso Academy&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d %d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;var1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;var2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this piece of code we are printing the sequence of characters and integers with the help of function '&lt;strong&gt;printf&lt;/strong&gt;' which is provided by C standard library.&lt;/p&gt;

&lt;p&gt;Explaining few things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;'&lt;em&gt;\n&lt;/em&gt;' : Is an escape sequence that moves the cursor to the next line. So whatever comes after it in the terminal starts on a fresh line. That's the main job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;'&lt;em&gt;%d&lt;/em&gt;' : Is the placeholder for variable with an integer value. When we want to print an integer value is have to assign a decimal[%d] placeholder inside the &lt;em&gt;printf&lt;/em&gt; strings and then assign our desired variable as shown in above example. One point to look out for when we are printing multiple values we have to assign the variable in order. by following the above example we have var1 and var2. Taking &lt;strong&gt;var1 = 3&lt;/strong&gt; and &lt;strong&gt;var2 = 4&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- If we print it we get this result: 3 4 
- If we swap and place var2 first and then var1 second : 4 3 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Though seeing it here won't feel like a big thing but what if we are doing some arithmetic operations and we need to correctly print some values in correct order we need to place the variables at their right place.&lt;/p&gt;




&lt;p&gt;Check out my GitHub repo to see the Codes for this Day : &lt;a href="https://github.com/mayank2patel/My_C-DS_Learning-Project.git" rel="noopener noreferrer"&gt;https://github.com/mayank2patel/My_C-DS_Learning-Project.git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>c</category>
    </item>
    <item>
      <title>Day 02 — How C Source Code Becomes an Executable</title>
      <dc:creator>Mayank</dc:creator>
      <pubDate>Tue, 09 Jun 2026 17:30:21 +0000</pubDate>
      <link>https://dev.to/low-level-systems/day-02-how-c-source-code-becomes-an-executable-39l4</link>
      <guid>https://dev.to/low-level-systems/day-02-how-c-source-code-becomes-an-executable-39l4</guid>
      <description>&lt;h2&gt;
  
  
  What I Learned Today
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why we need a Compiler.&lt;/li&gt;
&lt;li&gt;How C source code is compiled to executable [CPU readable instructions].&lt;/li&gt;
&lt;/ol&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why we need a Compiler
&lt;/h2&gt;

&lt;p&gt;Suppose we need to print Hello in our terminal but our CPU only understand 0's and 1's. Though we can write it in 0's and 1's for Hello but what if we need to calculate some big number we can't always write in 0's and 1's it's tedious task. Though you can write it if you have few screws loose.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;But&lt;/em&gt; we can write in human readable format and then use another program to convert it into Machine codes. Yes, That where our Compiler comes in.&lt;/p&gt;

&lt;p&gt;Writing C code in a file don't make it a C code it will remain a text file if we don't follow the syntax rules of C, save that file with .c extension and use a C compiler to convert it into an executable file that can be read by CPU.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source code -&amp;gt; executable
&lt;/h2&gt;

&lt;p&gt;In this piece of code it prints : Hello, World!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;#include : Is the Directive, It provide Declarations for the functions we are using.&lt;/li&gt;
&lt;li&gt;int main() : function named main -&amp;gt; The entry point of the program from where the OS will load the program step by step.&lt;/li&gt;
&lt;li&gt;printf("Hello, World!") : printf functions that we are using from stdio[Standard Input/Output Library] to print our string on terminal.&lt;/li&gt;
&lt;li&gt;return 0 : OS returns this integer when program is successfully executed.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Now we will look into how a source code is converted to executable code.&lt;/p&gt;

&lt;p&gt;When we run compile our code by using this command : gcc -Wall -o hello hello.c&lt;/p&gt;

&lt;p&gt;Here,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;gcc : Compiler we are using -&amp;gt; gcc [GNU C Compiler&lt;/li&gt;
&lt;li&gt;Wall : "Warn all" It's a compilation flag that gives us a broad sets of warning for code constructs.&lt;/li&gt;
&lt;li&gt;o : To specify the name of the output file. Without this if we compile our program it will always give a default executable called a.out&lt;/li&gt;
&lt;li&gt;hello : Name of our executable&lt;/li&gt;
&lt;li&gt;hello.c : Name of our program with .c extension&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It takes 3 steps to compile and then give us our executable code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pre-Processing : The Pre-Processing only looks for line starting with '#', line starting with # is called directive. Directive hold the header files for the functions we are using in our code it's 'stdio.h'. Which holds the Declarations for that functions. When Pre-Processor start it will look for '#' after finding it, the Pre-Processor replace that directive with the actual code of the header file.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- It will give us expanded C code.
- To test it out write : gcc -E hello.c
- The output of the Pre-Processing step is expanded C code(stdio.h header file + our program code)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Compiler : In this step the compiler takes the expanded C code and convert it into CPU instructions[Binary code/Machine code].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linker : Take the Machine code and the C library(In this case our standard Library) which have the compiled code needed by our functions to work in our case printf compiled code is present in the C standard Library. Linker stitches everything and finally provide an executable file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>c</category>
      <category>beginners</category>
      <category>basics</category>
    </item>
    <item>
      <title>printf("Hello\n");</title>
      <dc:creator>Mayank</dc:creator>
      <pubDate>Tue, 09 Jun 2026 17:04:53 +0000</pubDate>
      <link>https://dev.to/low-level-systems/printfhellon-nc7</link>
      <guid>https://dev.to/low-level-systems/printfhellon-nc7</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;I'm Mayank, and I'm starting my journey into low-level programming by learning and building in C. I know it's a long and hard road, but I'm committed to exploring this space and understanding how things work at the ground level.&lt;/p&gt;

&lt;p&gt;I'll be posting here every weekday — sharing what I learned that day, the code I wrote, and the concepts I ran into. Everything is also on my GitHub repo if you want to follow along or look at the code directly.&lt;/p&gt;

&lt;p&gt;I'm learning in public on purpose. If I get something wrong, I want to know. If you see a mistake in my understanding or my code, please point it out — that's exactly why I'm posting here.&lt;br&gt;
Let's see how far this goes.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>c</category>
    </item>
  </channel>
</rss>
