<?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: Thiago</title>
    <description>The latest articles on DEV Community by Thiago (@thiago_baruff).</description>
    <link>https://dev.to/thiago_baruff</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%2F4093984%2F7ca38fb2-26aa-4cc5-bde8-9c7c527ceddf.jpg</url>
      <title>DEV Community: Thiago</title>
      <link>https://dev.to/thiago_baruff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thiago_baruff"/>
    <language>en</language>
    <item>
      <title>Imperative Programming - What I learned for my test on Friday</title>
      <dc:creator>Thiago</dc:creator>
      <pubDate>Tue, 25 Aug 2026 15:03:37 +0000</pubDate>
      <link>https://dev.to/thiago_baruff/imperative-programming-what-i-learned-for-my-test-on-friday-260g</link>
      <guid>https://dev.to/thiago_baruff/imperative-programming-what-i-learned-for-my-test-on-friday-260g</guid>
      <description>&lt;p&gt;Welcome to my profile! My name is Thiago, I'm a student of Computer Science and a trainee in IT Support in a private company. The idea of this post is to help me remember the content before taking the test I'll have on, you'll never guess: this Friday! I also hope that it helps other people interested in the subject.&lt;/p&gt;




&lt;h2&gt;
  
  
  Concept
&lt;/h2&gt;

&lt;p&gt;Imperative Programming is the first programming paradigm that is studied in college, even if it's never mentioned by this term. You'll recognize it by the programming languages that are created from it —&lt;sup id="fnref1"&gt;1&lt;/sup&gt; C, Perl, JavaScript, etc — due to their simplicity and "direct" way of writing instructions: copying the imperative mood in natural languages ("&lt;em&gt;do this&lt;/em&gt;", or "&lt;em&gt;do that in this order&lt;/em&gt;"), telling the computer what (and &lt;strong&gt;how&lt;/strong&gt;) to do, step by step, using variables, and &lt;strong&gt;altering the state of the process&lt;/strong&gt; while executing. &lt;/p&gt;

&lt;p&gt;See below the details for each of the mentioned characteristics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exempli gratia
&lt;/h2&gt;

&lt;p&gt;Most of what I described above becomes clearer when using an example in C.&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;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;//Define 'a' as 0, 'b' as   5, and 'i' stays uninitialized&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;   &lt;span class="c1"&gt;//Define 'i' as 0, and while its value is lower than the value of 'b', execute the block of code below and add 1 to 'i' value&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;           &lt;span class="c1"&gt;//If 'i' equals 2, execute the block of code below&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="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Print in the terminal the value of 'i'&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;             &lt;span class="c1"&gt;//If the value isn't equal to 2, add 1 to 'a' value&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See how the whole code block, based on the comments of each line, is really inspired by the imperative mood? Beyond that, observe how the &lt;strong&gt;order&lt;/strong&gt; of commands is really specific.&lt;/p&gt;

&lt;p&gt;Furthermore, both the &lt;code&gt;for&lt;/code&gt; loop and &lt;code&gt;else&lt;/code&gt; statement lines are examples of altering the state of the process while executing it — the value of 'i' and 'a' changes constantly in the memory, so the computer never repeats its processes in the same way as before. &lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Sebesta, R. W. (2018). &lt;em&gt;Concepts of programming languages&lt;/em&gt; (12th ed.). Pearson.&lt;/li&gt;
&lt;li&gt;Imperative programming. (2026, August 15). In &lt;em&gt;Wikipedia&lt;/em&gt;. &lt;a href="https://en.wikipedia.org/wiki/Imperative_programming" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Imperative_programming&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;No AI was used in the writing of this post, I just really like using dashes.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

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