<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by spike on Medium]]></title>
        <description><![CDATA[Stories by spike on Medium]]></description>
        <link>https://medium.com/@spikenotes?source=rss-206810aab0e9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jj7Pg1u1SSX4f3c9GT6BXg.jpeg</url>
            <title>Stories by spike on Medium</title>
            <link>https://medium.com/@spikenotes?source=rss-206810aab0e9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:28:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@spikenotes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What conditional operator are in C?]]></title>
            <link>https://spikenotes.medium.com/what-conditional-operator-are-in-c-487a56197b85?source=rss-206810aab0e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/487a56197b85</guid>
            <category><![CDATA[c-language-tutorials]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[c-language]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c-tutorial]]></category>
            <dc:creator><![CDATA[spike]]></dc:creator>
            <pubDate>Thu, 17 Oct 2024 12:02:09 GMT</pubDate>
            <atom:updated>2024-10-17T12:02:09.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*dpbnEElgfL0YrH2c" /><figcaption>Image from: scaler.com</figcaption></figure><p>When writing code in C, simplicity and readability of the code are paramount. A particularly useful construct for simplifying code is the ternary operator (? :), also known as the conditional operator. This operator allows conditional choices to be made in a single expression, reducing the number of lines and making the code more concise.<br>The syntax of the ternary operator is as follows:</p><pre>condition ? espr_true : espr_false;</pre><p>Condition is a logical expression to be evaluated (returns true or false).<br>If condition is true (returns a value other than 0), espr_true is evaluated.<br>If condition is false (returns 0), it is evaluated espr_false.</p><p>The ternary operator allows simple conditional blocks, such as an if-else, to be solved in a single line.</p><p><strong><em>A Practical Example</em></strong><em>: Find the Maximum between Two Numbers.</em> Suppose we want to find the maximum value between two numbers a and b. The traditional way to do this with an if-else construct would be this:</p><pre>if (a &gt; b)<br> z = a;<br>else<br> z = b;</pre><p>Using the ternary operator, we can rewrite this code in a much more compact way:</p><pre>z = (a &gt; b) ? a : b;</pre><p>As you can see, the logic remains the same: if a is greater than b, then z is set to a; otherwise, it is set to b. However, thanks to the ternary operator, everything is encapsulated in a single expression.</p><p><strong><em>Converting Strings to Lower Case with the Ternary Operator.</em></strong></p><p>Let us now consider a more interesting example: converting the characters of a string to lower case. Typically, you use a while loop to cycle through the string and check whether each character is an uppercase letter. If it is, you convert it to lower case. Here is the traditional code:</p><pre>int i = 0;<br>while (s[i] != &#39;\0&#39;) {<br> if (s[i] &gt;= &#39;A&#39; &amp;&amp; s[i] &lt;= &#39;Z&#39;) {<br> s[i] = s[i] + (&#39;a&#39; - &#39;A&#39;);<br> }<br> ++i;<br>}</pre><p>By using the ternary operator, we can further simplify the code:</p><pre>int i = 0;<br>while (s[i] != &#39;\0&#39;) {<br> s[i] = (s[i] &gt;= &#39;A&#39; &amp;&amp; s[i] &lt;= &#39;Z&#39;) ? s[i] + (&#39;a&#39; - &#39;A&#39;) : s[i];<br> ++i;<br>}</pre><p>In a single expression within the while loop, a check is made as to whether the character is an uppercase letter. If the condition is true, the character is converted to lowercase, otherwise it remains unchanged.</p><p><strong>Data Types and Implicit Conversions.</strong></p><p>When using the ternary operator in C, one must be careful about the data type of the expressions being evaluated. If espr_true and espr_false are of different types, the compiler follows the implicit conversion rules of C. For example:</p><pre>float f = 5.5;<br>int n = 2;<br>x = (n &gt; 0) ? f : n;</pre><p>In this case, the ternary expression is of type float, since one of the expressions (f) is of type float, and C promotes the int type of n to float to achieve type consistency.</p><p>Advantages of the Ternary Operator</p><p><strong>The ternary operator offers several advantages:</strong></p><p>Conciseness: In many cases, code length can be reduced.<br>Clarity: For simple conditions, the ternary operator makes code more readable and less cumbersome than if-else blocks.<br>Efficiency: Using fewer lines of code can improve overall readability, making it easier to maintain and understand the code.</p><p>However, it is important not to overuse it. In complex situations, the ternary operator can make code more difficult to understand and maintain. In these cases, a traditional if-else approach may be preferable for clarity.<br>Conclusions</p><p>The ternary operator in C is a useful shortcut for handling simple conditions and assigning values concisely. Although its use can make code more compact, it is always important to balance conciseness and readability. Knowing how to use this operator wisely will allow you to write cleaner and more efficient code, saving time and improving the readability of your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=487a56197b85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the difference between ++i and i++ in programming?]]></title>
            <link>https://spikenotes.medium.com/what-is-the-difference-between-i-and-i-in-programming-d874508431f2?source=rss-206810aab0e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d874508431f2</guid>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <category><![CDATA[c-programming]]></category>
            <dc:creator><![CDATA[spike]]></dc:creator>
            <pubDate>Tue, 15 Oct 2024 15:59:57 GMT</pubDate>
            <atom:updated>2024-10-15T15:59:57.660Z</atom:updated>
            <content:encoded><![CDATA[<p>Didi you know that C and many other programming languages (Java, Rust, Ruby Perl, etc…) offer two unusual operators for increasing and decreasing variable values: ++ adds 1 to its operand, while — — subtracts 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*ZT3A-YEtMpMKJ0XC" /></figure><p>The unusual aspect of these operators lies in the fact that they can be written either as prefixes (++n) or suffixes (n++). In both cases the effect is to increment the value of n. However, the ++n instruction performs the increment before using the value of n, while n++ does so after the value is used.</p><p>It follows that in cases where the value is used, en not just the effect of the increment, the two forms lead to different results:</p><p>if n = 5, the instruction</p><pre>x = n++;</pre><p>sets the value of x to 5, while</p><pre>x = ++n;</pre><p>sets the value of x to 6.</p><p>In both cases the value of n becomes 6. The ++ and — — operands can be used only to variables. In contexts where no value is required, only the effect of the increment, as in</p><pre>if(a == 5){<br>  n++;<br>}</pre><p>the suffix and prefix forms are equivalent.</p><p>It is good practice to use ++i for most cases where there is no difference in behavior, for consistency and potential optimization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d874508431f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should learn C language]]></title>
            <link>https://spikenotes.medium.com/why-you-should-learn-c-language-0547f000f584?source=rss-206810aab0e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/0547f000f584</guid>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[c-language]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <dc:creator><![CDATA[spike]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 09:48:20 GMT</pubDate>
            <atom:updated>2024-10-13T09:48:20.313Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone and welcome to this introductory lesson on the C programming language, one of the most powerful and widely used programming languages in the world. In this lesson, we will explore what the C language is, how to write your first programs, and what tools you need to get started with programming in C. If you’re ready, let’s get started!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7kYAJBXzTNMXNTql4suhDA.jpeg" /></figure><p><strong>What is C language?</strong></p><p>The C language is a low-level programming language that originated in the 1970s for the development of the Unix operating system. C is considered low-level because it allows direct manipulation of memory and processor registers, giving the programmer significant control over the performance and efficiency of the code. The C language is also a structured language, meaning it is based on a series of instructions organized into logical blocks called functions. Additionally, it is a compiled language, which means it requires a phase of translation from source code to machine code before it can be executed.</p><p><strong>How to start coding in C:</strong></p><p>To write your first programs in C, you need to have a development environment, which is a set of tools that facilitate the writing, compiling, and executing of code. There are various development environments available for the C language, both free and paid, for operating systems such as Windows, Linux, and Mac. Some examples include: Visual Studio Code, Sublime Text, Eclipse, GCC, Notepad++.</p><p>Once you have chosen the development environment, you can start writing the source code in a file with the .c extension. The source code is the text that contains the instructions that the program must execute. The source code must follow the syntax rules of the C language; otherwise, the compiler will report errors. The compiler is the program that translates the source code into machine code, which is the language understandable by the processor. The machine code is then saved in a file with the .exe extension (on Windows) or .out (on Linux or Mac), which can be executed by the operating system.</p><p>Any program written in C will start executing from the main() function, so every source file must have one.</p><p>To write a program in C, it is necessary to define a main function, called ‘<strong>main</strong>’. The main function is the entry point of the program, meaning it is the first function that gets executed when the program starts. The main function has the following form:</p><pre>#include &lt;stdio.h&gt;<br>int main(){<br>  printf(&quot;Hello World!\n\&quot;);<br>  return 0;<br>}</pre><p>The stdio.h library is a standard library in C that provides input/output functions. The name stdio stands for “standard input/output.” The printf function that we use to print “Hello, World!” to the console is defined in this library. Therefore, we include stdio.h at the beginning of our program in order to use the printf function.</p><p>Today the C language is used for a variety of purposes like: System Programming, Embedded System, Game Development and more!</p><p><strong>Useful resources:</strong></p><p>Learning C requires time and dedication, but there are many resources available to help you along the way. One highly recommended source is the book by Dennis Ritchie, which provides valuable insights and a solid foundation in the C programming language. With persistence and the right materials, you can become proficient in C and unlock its powerful capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0547f000f584" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transistor: the invention that changed the world]]></title>
            <link>https://spikenotes.medium.com/transistor-the-invention-that-changed-the-world-a8bf5d13f321?source=rss-206810aab0e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8bf5d13f321</guid>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[transistor]]></category>
            <category><![CDATA[cpu]]></category>
            <dc:creator><![CDATA[spike]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 15:38:28 GMT</pubDate>
            <atom:updated>2024-09-29T15:38:28.160Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*JZ-E7xhUQHnm5LwvDUQ5qQ.jpeg" /></figure><p>About transistor</p><p>One of the most numerous electronic components found in computers is the <strong>transistor</strong>.</p><p>Whatever device you are using to read this text, be it a smarthphone or a pc, contains a processor composed of millions of microscopic tranisitors.</p><p>The M1 Max processor produced in 2021 by the Cupertino company is made from as many as 57 billion miniaturized transistors. An impressive number when we consider that they are all contained in about 400 mm², the size of a fly.</p><p>Transistor size comparison with a mitochondrion:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/0*6mCif9BvqG7ZiI_M.png" /></figure><p>Transistors can work like a switch as well as an amplifier, controlling the flow of electric current through them.</p><p>In the simplest of applications they are used as electrical switches. This behavior is the basis for the realization of fundamental logic gates such as: AND, OR, NOT, which form the building blocks of digital logic. By connecting in specific configurations several transistors, any logic gate can be realized.</p><p>There are many types of transistors with similar functionality to each other. The two most widely used are the <strong>BJT</strong> (the one we will analyze) and MOSFET.</p><h3>How are bjt made?</h3><p>BJT (<strong>B</strong>ipolar <strong>J</strong>unctio <strong>T</strong>ransistors) consist of three terminals:</p><p>-Emitter (E)</p><p>-Base (B), also called the “control terminal”.</p><p>-Collector (C)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/0*zYtSl-ebEFdT_S0z.png" /></figure><h4>Working.</h4><p>If the base (B) receives an input voltage, which is higher than a threshold voltage (0.6V — 0.7V), the transistor lets current flow between the emitter (E) and the collector (C).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/0*lcVZ7VMKVxjiBawo.png" /></figure><p>In this way, the BJT acts as a voltage-driven switch. When it is on (ON), it receives voltage at the base, “the switch” closes allowing current to flow through causing the bulb to turn on. On the opposite, if no voltage reaches the base, the transistor behaves as an open switch by cutting off the flow of current. The bulb will result in being turned off.</p><h4>How they are built</h4><p>Transistors are formed in Silicon or Germanium. Pure silicon is a semiconductor, meaning that able to conduct electricity and heat better than an insulating material but worse than a conductor.</p><p>The bjt transistor is made from 3 regions (N and P) joined together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*5Z5vcFy9XbRxvFXY.jpg" /></figure><p>(The base is much thinner than the emitter and collector regions.)</p><p>These regions are made through a process called <strong>doping</strong>, which involves introducing impurities into a pure semiconductor to change its electrical properties. In the case of an NPN transistor, the emitter region is typically doped with an element from group V of the periodic table, such as phosphorus. This doping process introduces an excess of electrons into the material, creating an electron concentration in the emitter. The base, on the other hand, is lightly doped with a group III element, such as boron, which creates an electron deficiency thus producing lacunae, or positive charge carriers. Finally, the collector is also doped like the emitter but with a lower concentration of electrons. The lacunae in the base area are fewer in number than the free electrons in the emitter.</p><h4>Electron movement</h4><p>When a voltage is applied between the emitter and the collector, with the base at a lower voltage than the collector, an electric field is created that “attracts” electrons from the emitter to the collector. The electrons leave from the emitter and are injected into the base, which being very thin and undoped, few electrons combine with the gaps. Most of the electrons continue on their way to the collector, driven by the electric field.</p><p>Once in the collector, the electrons create a current that flows through the circuit.</p><h4>Making the circuit</h4><p>If you have an Arduino (or similar) board, a breadboard a BJT transistor, an LED, a resistor and wires (jumpers) you can make a circuit to see the transistor in action.</p><p>In this test we are going to turn the red LED on and off by applying and removing voltage to the base of the transistor.</p><p>The base will be connected to pin 2 of the Arduino board, which will cycle the pin (ON — OFF).</p><p><strong>wiring diagram:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*94MpoPJzPLo5GnIY.png" /></figure><p><strong>code:</strong></p><p>to be uploaded to the Arduino board</p><pre>const int ledPin = 2;<br></pre><pre>const int delayTime = 1000; // 1000 ms = 1 sec</pre><pre>void setup() {<br>  <br>  pinMode(ledPin, OUTPUT);<br>}</pre><pre>void loop() {<br>  // PIN ON<br>  digitalWrite(ledPin, HIGH);<br>  // wait<br>  delay(delayTime);<br>  // PIN OFF<br>  digitalWrite(ledPin, LOW);<br>  // wait<br>  delay(delayTime);<br>}</pre><p>You can also use a simple switch to control the input signal at the base of the transistor without having to use an Arduino board.</p><h4>How are they made?</h4><p>Making such a small device is not at all an easy challenge. Few companies are capable of making processors with billions of these small components. If we are able to do so today, it is only because of the enormous research and development efforts of the past years. The complexity behind the mass production of processors is mind-blowing.</p><p>To explore more, this YouTube video clearly describes the entire mechanism of microprocessor production: <a href="https://youtu.be/dX9CGRZwD-w?si=ZWqCJH8OUsNSq-VJ">How are Microchips Made</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8bf5d13f321" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>