<?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: Abdulsalam Yusuf</title>
    <description>The latest articles on DEV Community by Abdulsalam Yusuf (@hyoukarh).</description>
    <link>https://dev.to/hyoukarh</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1139985%2F6bb781a0-e92f-48e3-9e5c-912d4fec0762.jpeg</url>
      <title>DEV Community: Abdulsalam Yusuf</title>
      <link>https://dev.to/hyoukarh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hyoukarh"/>
    <language>en</language>
    <item>
      <title>Memory layout in C</title>
      <dc:creator>Abdulsalam Yusuf</dc:creator>
      <pubDate>Mon, 22 Jul 2024 16:48:48 +0000</pubDate>
      <link>https://dev.to/hyoukarh/memory-layout-in-c-399a</link>
      <guid>https://dev.to/hyoukarh/memory-layout-in-c-399a</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Memory layout refers to how a computer’s memory is organized and structured. It defines how memory is divided and utilized by various system components.&lt;/p&gt;

&lt;p&gt;This is crucial in C as it directly impacts how variables, functions, and data structures are stored and accessed during execution.&lt;/p&gt;

&lt;p&gt;In this article, &lt;strong&gt;we’ll learn about the fundamental aspects of the memory layout in the C.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Segments In C’s Memory Layout
&lt;/h2&gt;

&lt;p&gt;The memory layout in C consists of different segments, below are the segments;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Text(Code) segment.&lt;/li&gt;
&lt;li&gt;Data segment.&lt;/li&gt;
&lt;li&gt;Heap.&lt;/li&gt;
&lt;li&gt;Stack. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The diagram below depicts C’s memory layout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rl96t7bb9kn41zux71f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rl96t7bb9kn41zux71f.png" alt="Diagram of C’s memory layout." width="741" height="361"&gt;&lt;/a&gt;&lt;br&gt;
Now let’s discuss the segments in detail.&lt;/p&gt;
&lt;h3&gt;
  
  
  Text(code) Segment
&lt;/h3&gt;

&lt;p&gt;The text segment is a region of memory in a C program that stores the compiled machine code instructions. These instructions constitute the executable logic of the program and are responsible for defining its behavior.&lt;/p&gt;

&lt;p&gt;Here's a simple example to illustrate the concept of the text segment in a C program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

int main() {
    int x = 5;
    int y = 10;
    int sum;

    sum = x + y;
    printf("The sum of %d and %d is %d\n", x, y, sum);

    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The compiler converts the source code into machine code when this program is compiled. This machine code constitutes the logic and behavior of a program and is stored in the text segment. &lt;/p&gt;

&lt;p&gt;While we can't directly see the machine code. We can understand that the text segment contains the compiled instructions.&lt;/p&gt;

&lt;p&gt;Essentially, the text segment holds instructions that define how the program behaves when it's executed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data segment
&lt;/h3&gt;

&lt;p&gt;The data segment is divided into two parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialized data segment&lt;/li&gt;
&lt;li&gt;uninitialized data segment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Initialized Data Segment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The initialized data segment consists of global, extern, static(both local and global), and constant global variables initialized beforehand. The initialized data segment has two sections, the &lt;strong&gt;read-only&lt;/strong&gt; and &lt;strong&gt;read-write&lt;/strong&gt; sections. &lt;/p&gt;

&lt;p&gt;Variables with predefined values that can be modified i.e. initialized global, extern, and static(both local and global) variables are stored in the &lt;strong&gt;read-write&lt;/strong&gt; section. Constant variables on the other hand come under the &lt;strong&gt;read-only&lt;/strong&gt; section.&lt;/p&gt;

&lt;p&gt;Here's an example illustrating variables stored in the initialized data segment, both in the read-write and read-only sections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

// Global variable (read-write section)
int globalVar = 10;

// External variable declaration (read-write section)
extern int externVar;

// Static global variable (read-write section)
static int staticGlobalVar = 20;

// Constant global variable (read-only section)
const int constGlobalVar = 30;

int main() {
    globalVar += 5;
    staticGlobalVar += 10;

    printf("Global variable: %d\n", globalVar);
    printf("Extern variable: %d\n", externVar);  // Assuming externVar is defined in another file
    printf("Static global variable: %d\n", staticGlobalVar);
    printf("Constant global variable: %d\n", constGlobalVar);

    return 0;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This illustrates variables stored in the read-write and read-only sections of the initialized data segment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uninitialized Data Segment&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The uninitialized data segment also known as BSS(Block started by symbol) segment consists of uninitialized global, extern, and static(both local and global) variables.&lt;/p&gt;

&lt;p&gt;These variables are initialized to zero by default before the program's execution. They have read-write permissions. Thus allowing them to be both read from and written to during the program's execution.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

// Uninitialized global variable (goes to the BSS segment)
int globalVar;

// Uninitialized static global variable (also goes to the BSS segment)
static int staticGlobalVar;

int main() {
    // Uninitialized local static variable (goes to the BSS segment)
    static int staticLocalVar;

    printf("Uninitialized Global Variable: %d\n", globalVar);
    printf("Uninitialized Static Global Variable: %d\n", staticGlobalVar);
    printf("Uninitialized Static Local Variable: %d\n", staticLocalVar);
    return 0;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this program, the uninitialized variables will contain zero or null values by default. This is due to automatic initialization by the compiler. This shows the behavior of variables stored in the BSS segment.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Heap
&lt;/h3&gt;

&lt;p&gt;The heap is a region of memory used for dynamic memory allocation during runtime. This allows memory to be allocated and released as needed during program execution. Functions such as &lt;strong&gt;malloc()&lt;/strong&gt;, &lt;strong&gt;calloc()&lt;/strong&gt;, &lt;strong&gt;realloc()&lt;/strong&gt;, and &lt;strong&gt;free()&lt;/strong&gt; are used for memory allocation and deallocation in the heap. The heap is accessible to all parts of the program.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

int main() {
    // Dynamically allocate memory for an integer variable on the heap
    int *ptr = (int *)malloc(sizeof(int));

    return 0;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code snippet demonstrates a simple use of dynamic memory allocation in C. It draws attention to the steps involved in requesting memory, initializing a pointer to that memory, and managing memory properly to avoid leaks. While error handling and memory deallocation are not included in this example, these are crucial components of working with dynamic memory in practical applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stack
&lt;/h3&gt;

&lt;p&gt;The stack segments primary function is to manage function calls and store local variables. This part is crucial in a program's memory layout, as it controls the flow within a program. The stack adopts a Last In, First Out (LIFO) structure, meaning the most recently added data is removed first. This makes the stack very efficient for managing local variables and nested function calls.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

void functionA(int n) {
    int a = n + 1; // Local variable
    printf("In functionA, a = %d\n", a);
}

void functionB() {
    int b = 10; // Local variable
    printf("In functionB, b = %d\n", b);
    functionA(b); // Call to functionA
}

int main() {
    int x = 20; // Local variable
    printf("In main, x = %d\n", x);
    functionB(); // Call to functionB
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code explains how stack frames store local variables. New stack frames are created by the function calls and are eliminated when the functions return. The printf instructions facilitate the visualization of each function's local variable values. The execution flow follows the calls to and returns from functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;C programmers can improve their coding techniques and gain a better understanding of how their programs interact with memory by mastering these concepts. Understanding memory layout is a vital skill in your programming toolbox, whether you're optimizing for performance or troubleshooting a complex problem.&lt;/p&gt;

&lt;p&gt;Feel free to follow, comment, and leave claps. Happy Coding!&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="http://www.linkedin.com/in/abdulsalam-yusuf-090b63238" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>c</category>
      <category>tutorial</category>
      <category>code</category>
      <category>programming</category>
    </item>
    <item>
      <title>“Is 2024 a Leap Year?”, Here’s how to check, using C language.</title>
      <dc:creator>Abdulsalam Yusuf</dc:creator>
      <pubDate>Wed, 17 Jan 2024 09:49:15 +0000</pubDate>
      <link>https://dev.to/hyoukarh/is-2024-a-leap-year-heres-how-to-check-using-c-language-4o9p</link>
      <guid>https://dev.to/hyoukarh/is-2024-a-leap-year-heres-how-to-check-using-c-language-4o9p</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;What is a leap year?:&lt;/p&gt;

&lt;p&gt;A leap year is a year that is a day longer than other years, i.e. it has 366 days instead of 365 days.&lt;/p&gt;

&lt;p&gt;When is the extra day?:&lt;/p&gt;

&lt;p&gt;In a leap year, the extra day is the 29th of February, instead of the normal 28 days. This extra day brings the total number of days to 366 days.&lt;/p&gt;

&lt;p&gt;Why do leap years exist?:&lt;/p&gt;

&lt;p&gt;Leap years exist to adjust our calendar system. To keep it synchronized with the Earth's orbit around the Sun.&lt;/p&gt;

&lt;p&gt;In this article, you’ll write a program in C to check if a year is a leap year, or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Understanding of the basics of C programming and its syntax.&lt;/li&gt;
&lt;li&gt;An integrated development environment is set up on your machine.&lt;/li&gt;
&lt;li&gt;Basic knowledge of your integrated development environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Terminologies to understand to aid with this lesson
&lt;/h2&gt;

&lt;p&gt;The rules for leap years are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If a year is divisible by 4 without remainder, it is a leap year.&lt;/li&gt;
&lt;li&gt;For centurial years, if it is divisible without remainder by 100 but not 400, it is not a leap year.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;Let’s begin, you’ll create a program in C language to check if a year is a leap year.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 - Set up your IDE(Integrated Development Environment)
&lt;/h3&gt;

&lt;p&gt;Create a file in your IDE that’ll store your source code. This is a fundamental step in establishing a well-organized and efficient development environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 - Header File
&lt;/h3&gt;

&lt;p&gt;Include the standard input/output library.&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/code&gt; includes the standard input/output library. Which is necessary to use functions like &lt;code&gt;printf&lt;/code&gt; and &lt;code&gt;scanf&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 -Declare Variable
&lt;/h3&gt;

&lt;p&gt;Declare a variable.&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;year&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An integer variable named &lt;code&gt;year&lt;/code&gt; is declared. This variable will store the user-inputted year.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 - User-Input
&lt;/h3&gt;

&lt;p&gt;Code to accept user input is required.&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="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter year: "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;scanf&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="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;printf("Enter year: ");&lt;/code&gt; prompts the user to enter a year. While &lt;code&gt;scanf("%d", &amp;amp;year);&lt;/code&gt; reads the inputted year and stores it in the variable &lt;code&gt;year&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 - Leap Year Check
&lt;/h3&gt;

&lt;p&gt;Next, you’ll write your code to check if the year inputted is a leap year or not.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5.1 - If Statement**
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;400&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="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 is a leap year"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;year&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 &lt;code&gt;if&lt;/code&gt; statement checks if the inputted year is divisible by 400 without remainder. If it is, a message indicating it is a leap year will be printed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5.2 - else if statement**
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;4&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="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 is a leap year"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;year&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;If the condition is not met in the first &lt;code&gt;if&lt;/code&gt; statement, the program moves to the &lt;code&gt;else if&lt;/code&gt; statement. if the inputted year is divisible by 4, it’ll print a message indicating it is a leap year.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5.3 - else statement**
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;else&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 is not a leap year"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;year&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;If both conditions in the &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else if&lt;/code&gt; statements are not satisfied, the program executes the &lt;code&gt;else&lt;/code&gt; statement. This means the year inputted is not divisible by 400 and 4 without remainder. A message indicating the year is not a leap year will be printed in this case.&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="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="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This indicates the successful execution of the program.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6 - Execute Code
&lt;/h3&gt;

&lt;p&gt;Now, you’ll check if &lt;strong&gt;2024&lt;/strong&gt; is a leap year or not.&lt;/p&gt;

&lt;p&gt;In your IDE, run your code and input 2024 as the user input when prompted to “Enter year:”.&lt;/p&gt;

&lt;p&gt;As 2024 can be divided by 4 without remainder, your terminal would return the output below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjm1zrpj3ox1305p8scq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjm1zrpj3ox1305p8scq.png" alt="Terminal output showing " width="209" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s see what happens when we enter &lt;strong&gt;2023&lt;/strong&gt; when prompted to “Enter year”.&lt;/p&gt;

&lt;p&gt;As 2023 cannot be divided by 400 or 4 without remainder, the output below will be printed on your terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9jy3q5pl8imzp8uvrq9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9jy3q5pl8imzp8uvrq9.png" alt="Terminal output showing " width="263" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations!, you’ve successfully run a program to check if 2024 is a leap year. By utilizing some basic syntax in C, you’ve gained experience with how functions like &lt;code&gt;printf&lt;/code&gt;, &lt;code&gt;scanf&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else if&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt; statements work.&lt;/p&gt;

&lt;p&gt;If you enjoyed this article, please follow, like, and leave a comment. Let’s connect on &lt;a href="http://www.linkedin.com/in/abdulsalam-yusuf-090b63238" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>c</category>
      <category>tutorial</category>
      <category>code</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to write a simple C program to check if a number is prime using Visual Studio code.</title>
      <dc:creator>Abdulsalam Yusuf</dc:creator>
      <pubDate>Fri, 29 Dec 2023 16:05:03 +0000</pubDate>
      <link>https://dev.to/hyoukarh/how-to-write-a-simple-c-program-to-check-if-a-number-is-prime-using-visual-studio-code-mld</link>
      <guid>https://dev.to/hyoukarh/how-to-write-a-simple-c-program-to-check-if-a-number-is-prime-using-visual-studio-code-mld</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;C is a procedural language. it is renowned for its portability, efficiency, and simple syntax.&lt;/p&gt;

&lt;p&gt;Visual Studio Code is a development tool. Inbuilt with a code editor that supports development processes and more.&lt;/p&gt;

&lt;p&gt;In this article, you’ll learn to write a simple C program to check if a number is prime using Visual Studio Code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisite
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Basic knowledge of C programming and its syntax.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visual Studio Code is installed on your machine. Go to the &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;official website&lt;/a&gt; to install it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Terminologies to understand to aid with this lesson
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Prime number - This is a number that can only be divided by one and itself, for example, 2, 3, 5, 7… etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Composite number - is a positive integer divided by 1 and other numbers apart from itself, for example, 4, 6, 8, 9… etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;p&gt;Let’s dive in by breaking down the processes involved in this article.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 - Download Extensions
&lt;/h3&gt;

&lt;p&gt;Extensions are software that extends and enhances the functionality of the editor.&lt;/p&gt;

&lt;p&gt;Launch Visual Studio Code and click on &lt;strong&gt;Extensions&lt;/strong&gt;. It can also be accessed using the shortcut keys &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;shift&lt;/code&gt;+X or the &lt;code&gt;command&lt;/code&gt; key for MAC. Install the following extensions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;C/C++ Extension Pack:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;strong&gt;C/C++ Extension Pack&lt;/strong&gt; provides a comprehensive development environment for C and C++ programming in Visual Studio Code. This extension pack includes essential tools, language support, debugging capabilities, and extra features tailored for C and C++ development.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7m826pfjauzau3dydi8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7m826pfjauzau3dydi8.png" alt="An image of C/C++ Extension Pack installation" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;C/C++ Extension:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;strong&gt;C/C++&lt;/strong&gt; extension is a core component within the extension pack. It focuses on providing language support for C and C++ in Visual Studio Code. This includes features such as syntax highlighting, code suggestions, debugging support, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfroxf09letprwb01ed6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfroxf09letprwb01ed6.png" alt="An image of C/C++ extension installation" width="800" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Code Runner:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;strong&gt;Code Runner&lt;/strong&gt; extension is a tool that allows the execution of code snippets or entire files&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnggpfgwncpao2dzpkwzl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnggpfgwncpao2dzpkwzl.png" alt="An image of Code Runner extension installation" width="800" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1.1 - Change Settings
&lt;/h4&gt;

&lt;p&gt;Click the gear icon on the bottom-left corner of your screen and click on &lt;strong&gt;Settings&lt;/strong&gt;. Or, use the shortcut keys &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;,&lt;/code&gt;, the &lt;code&gt;command&lt;/code&gt; key for Mac.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ptawibo5z85m0nk5tgq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ptawibo5z85m0nk5tgq.png" alt="An image of the gear icon and Settings" width="447" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, enable the &lt;strong&gt;Code-runner: Run In Terminal&lt;/strong&gt; feature.&lt;/p&gt;

&lt;p&gt;Input &lt;strong&gt;“run code in terminal”&lt;/strong&gt; in the search bar and check the &lt;strong&gt;Code-runner: Run In Terminal&lt;/strong&gt; checkbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folxgy8gyj3gxp2ugvrlt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folxgy8gyj3gxp2ugvrlt.png" alt="An image of the input “run code in terminal” in the search bar" width="778" height="278"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;strong&gt;Code-runner: Run In Terminal&lt;/strong&gt; feature allows user input in the terminal. In this lesson, user input handling is required. i.e. if your code prompts for user input, you can provide it within the terminal.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2 - Open a folder
&lt;/h3&gt;

&lt;p&gt;A folder has many uses such as file organization, namespace management, etc.&lt;/p&gt;

&lt;p&gt;Navigate the Explorer tab or use the shortcut keys &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;shift&lt;/code&gt;+&lt;code&gt;E&lt;/code&gt;, the &lt;code&gt;command&lt;/code&gt; key on Mac.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Open Folder&lt;/strong&gt; and proceed to create a new folder on your file explorer/manager.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdezn060b54fxfwvn73vf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdezn060b54fxfwvn73vf.png" alt="An image of Open Folder" width="421" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Name the folder whatever you want or you can name it “C”. Click Select Folder after.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3mq74zijkwqat0ehh9g7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3mq74zijkwqat0ehh9g7.png" alt="An image of New Folder and Select Folder" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 2.1 - Create a file
&lt;/h4&gt;

&lt;p&gt;A file serves many functions, in this lesson, you’ll be storing your source code in a file.&lt;/p&gt;

&lt;p&gt;Click on your folder, and beside it, three icons will appear, click the &lt;strong&gt;New File&lt;/strong&gt; icon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0jpl5pmwqfkc245rm2js.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0jpl5pmwqfkc245rm2js.png" alt="An image of the New File icon" width="278" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Name your file with the &lt;code&gt;.c&lt;/code&gt; extension to specify the C source code. Click enter to save the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyu14t6pm8hwacjgch55h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyu14t6pm8hwacjgch55h.png" alt="An image of a file with the .c extension" width="277" height="164"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3 - Code
&lt;/h3&gt;

&lt;p&gt;Your workspace is set up, Next, you’ll write your code to check if a number is prime. In your editor, follow the steps below:&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3.1 - Header file
&lt;/h4&gt;

&lt;p&gt;Include the standard input/output and math libraries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/code&gt; includes the standard input/output library. This library is used for input/output operations.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#include &amp;lt;math.h&amp;gt;&lt;/code&gt; includes the math library. This library is used for mathematical functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3.2 - Entry point
&lt;/h4&gt;

&lt;p&gt;Include the &lt;code&gt;int main()&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

int main()
{

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The int main function is the entry point, it returns an integer value(often 0) to state success. An entry point is where program execution starts.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3.3 - Declare variables and user input
&lt;/h4&gt;

&lt;p&gt;Declare Variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

int main()
{
    int number;
    int i, value1, value2, count = 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;int number&lt;/code&gt; stores the user input. While &lt;code&gt;int i, value1, value2, count = 0;&lt;/code&gt; declare variables for loop control, intermediate values, and a counter.&lt;/p&gt;

&lt;p&gt;Next, add code to accept user input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

int main()
{
    int number;
    int i, value1, value2, count = 0;
    printf("Enter a number: ");
    scanf("%d", &amp;amp;number);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;printf("Enter a number: ")&lt;/code&gt; prompts the user to enter a number. &lt;code&gt;scanf("%d", &amp;amp;number);&lt;/code&gt; reads the user input and stores it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3.4 - Find the square root
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

int main()
{
    int number;
    int i, value1, value2, count = 0;
    printf("Enter a number: ");
    scanf("%d", &amp;amp;number);

    value1 = ceil(sqrt(number));
    value2 = number;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;value1 = ceil(sqrt(number));&lt;/code&gt; calculates the square root of &lt;code&gt;number&lt;/code&gt; using the &lt;code&gt;sqrt&lt;/code&gt; function. The &lt;code&gt;ceil&lt;/code&gt; function approximates the square root to the nearest integer.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;value2 = number&lt;/code&gt; is initialized to the value of &lt;code&gt;number&lt;/code&gt;. This will be used in later calculations or conditions. i.e. the prime number checking logic.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3.5 - Loop iteration
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

int main()
{
    int number;
    int i, value1, value2, count = 0;
    printf("Enter a number: ");
    scanf("%d", &amp;amp;number);

    value1 = ceil(sqrt(number));
    value2 = number;

    for(i = 2; i &amp;lt;= value1; i++)
    {
        if(value2 % i == 0)
            count = 1;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop checks the divisibility of &lt;code&gt;value2&lt;/code&gt; by &lt;code&gt;i&lt;/code&gt;. If true, &lt;code&gt;count&lt;/code&gt; is set to 1, else it remains 0.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3.6 - Check if the number is prime
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

int main()
{
    int number;
    int i, value1, value2, count = 0;
    printf("Enter a number: ");
    scanf("%d", &amp;amp;number);

    value1 = ceil(sqrt(number));
    value2 = number;

    for(i = 2; i &amp;lt;= value1; i++)
    {
        if(value2 % i == 0)
            count = 1;
    }
    if((count == 0 &amp;amp;&amp;amp; value2 != 1) || value2 == 2 || value2 == 3)
    {
        printf("%d is a prime number", value2);
    }
    else
    { 
        printf("%d is not prime number", value2);
    }
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;if&lt;/code&gt; statement checks if the number is prime. If the conditions are true, it prints the number is a prime number, if false, it prints it is not a prime number. &lt;code&gt;return 0&lt;/code&gt; indicates the program has been executed successfully.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 - Run Code
&lt;/h3&gt;

&lt;p&gt;To run your code, click on the &lt;strong&gt;Run Code&lt;/strong&gt; icon on the top-left corner of your screen(first icon). Or use the shortcut keys &lt;code&gt;ctrl&lt;/code&gt;+&lt;code&gt;alt&lt;/code&gt;+&lt;code&gt;N&lt;/code&gt;, the &lt;code&gt;command&lt;/code&gt; key on Mac.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 - Terminal Input
&lt;/h3&gt;

&lt;p&gt;After clicking the &lt;strong&gt;Run Code&lt;/strong&gt; icon, the terminal will appear at the bottom of your screen. You will see a prompt that says “Enter a number” on the terminal. Please input a number in the terminal when prompted.&lt;/p&gt;

&lt;p&gt;If the number is prime, the output below is displayed;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8ilje5l6dutg3t6hvci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8ilje5l6dutg3t6hvci.png" alt="An image of the terminal" width="418" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Otherwise, this output below is displayed;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgpthhjbwiu3hjrzc205.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgpthhjbwiu3hjrzc205.png" alt="An image of the terminal" width="415" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial article, you wrote a C program to check if a number is prime. Also leveraging the capabilities of Visual Studio code as a powerful integrated development environment(IDE). You covered inputs, loops, and math functions. All basics for a solid foundation in C programming.&lt;/p&gt;

&lt;p&gt;If you enjoyed this tutorial and would like to learn more on this blog, feel free to follow, comment, and leave claps. Happy Coding!&lt;/p&gt;

&lt;p&gt;Let’s connect on &lt;a href="http://www.linkedin.com/in/abdulsalam-yusuf-090b63238" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

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