<?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: Dhanashree Rugi</title>
    <description>The latest articles on DEV Community by Dhanashree Rugi (@dhanashreerugi).</description>
    <link>https://dev.to/dhanashreerugi</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%2F853159%2F4708f103-e7d6-44f1-9fd2-d3ae12ca852d.png</url>
      <title>DEV Community: Dhanashree Rugi</title>
      <link>https://dev.to/dhanashreerugi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dhanashreerugi"/>
    <language>en</language>
    <item>
      <title>Length of Linked List.</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Wed, 17 Aug 2022 13:20:55 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/length-of-linked-list-ob8</link>
      <guid>https://dev.to/dhanashreerugi/length-of-linked-list-ob8</guid>
      <description>&lt;p&gt;For more such blogs visit " &lt;a href="http://www.coderlogs.com"&gt;www.coderlogs.com&lt;/a&gt; "&lt;/p&gt;

&lt;p&gt;For a given linked list, you are supposed to write a function that finds the length of that linked list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1 :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Input : Linked List : 4 6 8 2&lt;br&gt;
Output : Length of List : 4&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TOSDBBjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/ZKTpy2f/images.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TOSDBBjk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/ZKTpy2f/images.png" alt="image" width="365" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2 :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Input : Linked List : 1 3 1 2 1&lt;br&gt;
Output : Length of List : 5&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aNowal6w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/vvkjQcT/download.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aNowal6w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/vvkjQcT/download.png" alt="image" width="491" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declare and initialise a temporary pointer &lt;code&gt;temp&lt;/code&gt; as the &lt;code&gt;head&lt;/code&gt; node of the linked list.&lt;/li&gt;
&lt;li&gt;Initialise an integer variable &lt;code&gt;count&lt;/code&gt; as &lt;code&gt;zero(0)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Traverse the linked list using &lt;code&gt;temp&lt;/code&gt; and  increment the variable  &lt;code&gt;count&lt;/code&gt; by &lt;code&gt;one&lt;/code&gt; until &lt;code&gt;temp&lt;/code&gt; becomes &lt;code&gt;NULL&lt;/code&gt; i.e.,
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(temp != NULL)
{
   count++;
   temp = temp-&amp;gt;next;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Return or print the variable  &lt;code&gt;count&lt;/code&gt; which gives the length of the list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;C program that finds the length of the given linked list.&lt;/strong&gt;&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; 
#include &amp;lt;limits.h&amp;gt;

struct node
{
    int data;
    struct node * next;
};

void displayLL(struct node * head)
{
    struct node * temp;
    temp = head;
    temp=head;
    while(temp!=0)
    {
       printf("%d ",temp-&amp;gt;data);
       temp = temp-&amp;gt;next;
    }
}

void length(struct node *head)
{
    struct node *temp = head;
    int count = 0;

    while(temp != NULL)
    {
        count++;
        temp = temp-&amp;gt;next;
    }
    printf("\n--------------------------------\n");
    printf("Length of linked list : %d", count);
}
int main()
{
   struct node *head = 0, *newnode, *temp; 
   int n, choice, newdata;

// Create Linked List // 

   printf("Enter the number of nodes in the list : ");
   scanf("%d", &amp;amp;n);

   if(n == 0)
   {
      printf("--------------------------------\n");
      printf("Linked list cannot be empty");
      exit(0);
    } 

 for(int i = 1; i&amp;lt;=n; i++)
 {
   newnode = (struct node *)malloc(sizeof(struct node));
   printf("Enter the data%d : ", i);
   scanf("%d", &amp;amp;newnode-&amp;gt;data);
   newnode-&amp;gt;next = 0;
   if(head == 0)
     {
        head = temp = newnode;
     } 
   else
     { 
        temp-&amp;gt;next = newnode;
        temp = newnode;
      }
  }
   printf("--------------------------------\n");
   printf("Original linked list : ");
   displayLL(head);
   length(head);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>linkedlist</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Move Largest Number to the End of Linked List.</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Tue, 26 Jul 2022 07:18:07 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/move-largest-number-to-the-end-of-linked-list-4jjd</link>
      <guid>https://dev.to/dhanashreerugi/move-largest-number-to-the-end-of-linked-list-4jjd</guid>
      <description>&lt;p&gt;For a given linked list, you are supposed to write a function that moves the largest number  to the end of the list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;br&gt;
Input : 4 6 2 8 1&lt;br&gt;
Output : 4 6 2 1 8&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;br&gt;
Input : 9 5 1 8 2&lt;br&gt;
Output : 5 1 8 2 9&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To move the largest number  to the end, first you need to write the function that returns the &lt;a href="http://localhost:4001/post/62a1a437752339739aa908e1/largest-And-Smallest-Element-in-a-Linked-List"&gt;largest&lt;/a&gt;  number. Store that largest(maximum) number in an integer variable &lt;code&gt;max&lt;/code&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write the base case &lt;strong&gt;:&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;If  only one node is present in the linked list , then 
return &lt;code&gt;head&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If no node, then print  an error message. &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initialise two pointers : &lt;code&gt;prevnode&lt;/code&gt;  to point the previous node in the list and &lt;code&gt;temp&lt;/code&gt; to point  the &lt;code&gt;head&lt;/code&gt; node of the list. Both the pointers are of type &lt;code&gt;struct node&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare the value of &lt;code&gt;max&lt;/code&gt; with each number(data)  of  the linked list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the value of &lt;code&gt;max&lt;/code&gt; is equal to the first data of the linked list &lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Separate the &lt;code&gt;head&lt;/code&gt; node from the list, make &lt;code&gt;temp&lt;/code&gt; to point second node and make &lt;code&gt;prevnode&lt;/code&gt; to point &lt;code&gt;head&lt;/code&gt; node. &lt;/li&gt;
&lt;li&gt;Now, make second node as the &lt;code&gt;head&lt;/code&gt; node of the list by &lt;code&gt;head = temp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Traverse the linked list until last node and connect the detached node(to which pointer &lt;code&gt;prevnode&lt;/code&gt; is pointing) to the last node which contains the largest number of the linked list.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;If the value of &lt;code&gt;max&lt;/code&gt; equals to other than first data  in the list &lt;strong&gt;:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Traverse the linked list until number  is found equal to value of &lt;code&gt;max&lt;/code&gt; . If found, then detach that node from the linked list by &lt;code&gt;prevnode-&amp;gt;next = temp-&amp;gt;next&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a new node pointing to  by pointer &lt;code&gt;newnode&lt;/code&gt; and store the value of &lt;code&gt;max&lt;/code&gt; into that node using structure member &lt;code&gt;data&lt;/code&gt; and store &lt;code&gt;NULL&lt;/code&gt; into its address part using structure member &lt;code&gt;next&lt;/code&gt; i.e., 
&lt;code&gt;newnode-&amp;gt;data = max;
newnode-&amp;gt;next = NULL;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Traverse the linked list until last node and connect the &lt;code&gt;newnode&lt;/code&gt; to the last node which contains the largest number of the linked list.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Finally  display the new linked list with the  largest number at the end. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;C program that moves the largest number to the end of linked list.&lt;/strong&gt;&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; 
#include &amp;lt;limits.h&amp;gt;

struct node
{
    int data;
    struct node * next;
};

void displayLL(struct node * head)
{
    struct node * temp;
    temp = head;
    temp=head;
    while(temp!=0)
    {
       printf("%d ",temp-&amp;gt;data);
       temp = temp-&amp;gt;next;
    }
}

int large(struct node *head)
{
   struct node *temp = head;
   int max;
   max = INT_MIN;

   while(temp != NULL)
   {
       if(max &amp;lt; temp-&amp;gt;data)
       {
           max = temp-&amp;gt;data;
       }
       temp = temp-&amp;gt;next;
   }
   return max;
}

void largeToEnd(struct node *head)
{
    struct node *prevnode, *newnode;
    struct node *temp;
    int max;
    temp = head;

    if(head-&amp;gt;next == NULL)
    {
        printf("\n--------------------------------\n");
        printf("Linked list with largest number at end : ");
        displayLL(head);
        exit(0);
    }
    max = large(head);  

   if(head-&amp;gt;data == max)
    {
        temp = temp-&amp;gt;next;
        head-&amp;gt;next = NULL;
        prevnode = head;
        head = temp;
        while(temp-&amp;gt;next != NULL )
        {
            temp = temp-&amp;gt;next;
        }
        temp-&amp;gt;next = prevnode;
        printf("\n--------------------------------\n");
        printf("Linked list with largest number at end : ");
        displayLL(head);
        exit(0);
    }
    while(temp-&amp;gt;data != max)
    {
        prevnode = temp;
        temp = temp-&amp;gt;next;
    }

    prevnode-&amp;gt;next = temp-&amp;gt;next;

    newnode = (struct node *)malloc(sizeof(struct node));
    newnode-&amp;gt;data = max;
    newnode-&amp;gt;next = NULL;

    temp = head;

    while(temp-&amp;gt;next != NULL)
     {
        temp = temp-&amp;gt;next;
     }
    temp-&amp;gt;next = newnode;

    printf("\n--------------------------------\n");
    printf("Linked list with largest number at end : ");
    displayLL(head);
}    

int main()
{
   struct node *head = 0, *newnode, *temp; 
   int n, choice, newdata, max;

// Create Linked List // 

   printf("Enter the number of nodes in the list : ");
   scanf("%d", &amp;amp;n);

   if(n == 0)
   {
      printf("--------------------------------\n");
      printf("Linked list cannot be empty");
      exit(0);
   }
   for(int i = 1; i&amp;lt;=n; i++)
   {
     newnode = (struct node *)malloc(sizeof(struct node));
     printf("Enter the data%d : ", i);
     scanf("%d", &amp;amp;newnode-&amp;gt;data);
     newnode-&amp;gt;next = 0;
     if(head == 0)
     {
        head = temp = newnode;
     } 
     else
       { 
        temp-&amp;gt;next = newnode;
        temp = newnode;
       }
    }
   printf("--------------------------------\n");
   printf("Linked list : ");
   displayLL(head);
   max = large(head);
   printf("\n--------------------------------\n");
   printf("Largest number of linked list : %d", max);
   largeToEnd(head);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I own a website &lt;a href="http://www.coderlogs.com"&gt;www.coderlogs.com&lt;/a&gt; where in I write similar blogs so do visit the website for more such blog posts.&lt;/p&gt;

</description>
      <category>c</category>
      <category>linkedlist</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Align attribute in HTML</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Fri, 15 Jul 2022 14:37:55 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/align-attribute-in-html-4lce</link>
      <guid>https://dev.to/dhanashreerugi/align-attribute-in-html-4lce</guid>
      <description>&lt;p&gt;An important information to the beginners!&lt;/p&gt;

&lt;p&gt;While designing my first &lt;strong&gt;HTML&lt;/strong&gt; website I came across that &lt;strong&gt;HTML5&lt;/strong&gt; does not support &lt;strong&gt;align&lt;/strong&gt;(&lt;strong&gt;centre, left, right&lt;/strong&gt;) attribute as it is removed from the &lt;strong&gt;HTML5&lt;/strong&gt; document.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p align = "centre"&amp;gt; Coderlogs &amp;lt;/p&amp;gt;   // not supported format //
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the CSS text-align property to &lt;strong&gt;centre&lt;/strong&gt; any &lt;strong&gt;text&lt;/strong&gt; or object or &lt;strong&gt;form&lt;/strong&gt; in HTML.&lt;/p&gt;

&lt;p&gt;Stay tuned!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>Create a Copy of a Linked List</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Wed, 13 Jul 2022 09:21:14 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/create-a-copy-of-a-linked-list-1blh</link>
      <guid>https://dev.to/dhanashreerugi/create-a-copy-of-a-linked-list-1blh</guid>
      <description>&lt;p&gt;For a given linked list, you are supposed to write a function that creates a copy of the already created linked list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;br&gt;
Input : Linked List : 4 6 2 8 1&lt;br&gt;
Output : Copy of linked list : 4 6 2 8 1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;br&gt;
Input : Linked List : 4 5 9 8 2&lt;br&gt;
Output : Copy of linked list : 4 5 9 8 2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logic behind this is just create a new node of structure and copy the every existing node to new node.&lt;/li&gt;
&lt;li&gt;Process will continue until the existing list leads to null(recursively).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;C program that creates the copy of linked list:&lt;/strong&gt;&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; 
#include &amp;lt;limits.h&amp;gt;

struct node
{
    int data;
    struct node * next;
};

void displayLL(struct node * head)
{
    struct node * temp;
    temp = head;
    temp=head;
    while(temp!=0)
    {
       printf("%d ",temp-&amp;gt;data);
       temp = temp-&amp;gt;next;
    }
}

void copy(struct node *head)
{
    struct node *temp = head;
    struct node *temp1, *temp2, *head1;

    temp1 = (struct node *)malloc(sizeof(struct node));
    temp1-&amp;gt;next = NULL;
    temp1-&amp;gt;data = temp-&amp;gt;data;
    head1 = temp1;
    temp1-&amp;gt;next = NULL;
    temp = temp-&amp;gt;next;

    while(temp != NULL)
    {
       temp2 = (struct node *)malloc(sizeof(struct node));
       temp2-&amp;gt;data = temp-&amp;gt;data;
       temp1-&amp;gt;next = temp2;
       temp1 = temp2;
       temp = temp-&amp;gt;next;
    }
    printf("\n--------------------------------\n");
    printf("Copy of original linked list : ");
    displayLL(head1);
}

int main()
{
   struct node *head = 0, *newnode, *temp; 
   int n, choice, newdata;

// Create Linked List // 

   printf("Enter the number of nodes in the list : ");
   scanf("%d", &amp;amp;n);

   if(n == 0)
   {
      printf("--------------------------------\n");
      printf("Linked list cannot be empty");
      exit(0);
    } 

   for(int i = 1; i&amp;lt;=n; i++)
   {
     newnode = (struct node *)malloc(sizeof(struct node));
     printf("Enter the data%d : ", i);
     scanf("%d", &amp;amp;newnode-&amp;gt;data);
     newnode-&amp;gt;next = 0;
     if(head == 0)
     {
        head = temp = newnode;
     } 
     else
       { 
        temp-&amp;gt;next = newnode;
        temp = newnode;
       }
    }
   printf("--------------------------------\n");
   printf("Original linked list : ");
   displayLL(head);
   copy(head);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter the number of nodes in the list : 4
Enter the data1 : 3
Enter the data2 : 7
Enter the data3 : 3
Enter the data4 : 8
--------------------------------
Original linked list : 3 7 3 8 
--------------------------------
Copy of original linked list : 3 7 3 8 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>beginners</category>
      <category>linkedlist</category>
    </item>
    <item>
      <title>Find Largest And Smallest Number in a Linked List.</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Tue, 05 Jul 2022 12:52:12 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/find-largest-and-smallest-number-in-a-linked-list-3k11</link>
      <guid>https://dev.to/dhanashreerugi/find-largest-and-smallest-number-in-a-linked-list-3k11</guid>
      <description>&lt;p&gt;For a given linked list, you are supposed to write two separate functions that finds the largest and the smallest number  in a linked list and print both the numbers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;br&gt;
Input: 4 6 2 8 1 &lt;br&gt;
Output: Largest Number: 8&lt;br&gt;
Output: Smallest Number: 1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;br&gt;
Input: 4 5 9 8 2&lt;br&gt;
Output: Largest Number: 9&lt;br&gt;
Output: Smallest Number: 2 &lt;/p&gt;
&lt;h2&gt;
  
  
  Steps to find Largest number:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initialise an integer variable &lt;code&gt;max&lt;/code&gt; to &lt;code&gt;INT_MIN&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using temporary pointer &lt;code&gt;temp&lt;/code&gt; start traversing the linked list and compare each data element  in the linked list with the variable &lt;code&gt;max&lt;/code&gt; until the end of linked list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the current node’s data is greater than value of &lt;code&gt;max&lt;/code&gt;, then store the value of the current node’s data into &lt;code&gt;max&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, print the value of  variable &lt;code&gt;max&lt;/code&gt; which contains the largest number  of the linked list.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Steps to find Smallest number:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Initialise an integer variable &lt;code&gt;min&lt;/code&gt; to &lt;code&gt;INT_MAX&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using temporary pointer &lt;code&gt;temp&lt;/code&gt; start traversing the linked list and compare each data element in the linked list with the variable &lt;code&gt;min&lt;/code&gt; until the end of linked list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the current node’s data is lesser than the value of &lt;code&gt;min&lt;/code&gt;, then store the value of the current node’s data into &lt;code&gt;min&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, print the value of variable &lt;code&gt;min&lt;/code&gt; which contains the smallest number  of the linked list.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note : We are using INT_MAX because all the data elements are lesser than this and INT_MIN because all the data elements are greater than this. Using these two macros our findings become very easy.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C program that finds the largest and the smallest number in the linked list.&lt;/strong&gt;&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; 
#include &amp;lt;limits.h&amp;gt;

struct node
{
    int data;
    struct node * next;
};

void displayLL(struct node * head)
{
    struct node * temp;
    temp = head;
    temp=head;
    while(temp!=0)
    {
       printf("%d ",temp-&amp;gt;data);
       temp = temp-&amp;gt;next;
    }
}
void small(struct node *head)
{
   struct node *temp = head;
   int min;
   min = INT_MAX;

   while(temp != NULL)
   {
       if(min &amp;gt; temp-&amp;gt;data)
       {
           min = temp-&amp;gt;data;
       }
       temp = temp-&amp;gt;next;
   }
   printf("\n--------------------------------\n");
   printf("Smallest number of linked list : %d", min);
}

void large(struct node *head)
{
   struct node *temp = head;
   int max;
   max = INT_MIN;

   while(temp != NULL)
   {
       if(max &amp;lt; temp-&amp;gt;data)
       {
           max = temp-&amp;gt;data;
       }
       temp = temp-&amp;gt;next;
   }
   printf("\n--------------------------------\n");
   printf("Largest number of linked list : %d", max);
}

int main()
{
   struct node *head = 0, *newnode, *temp; 
   int n, choice, newdata;

// Create Linked List // 

   printf("Enter the number of nodes in the list : ");
   scanf("%d", &amp;amp;n);

   if(n == 0)
    {
      printf("--------------------------------\n");
      printf("Linked list cannot be empty");
      exit(0);
    }

   for(int i = 1; i&amp;lt;=n; i++)
   {
     newnode = (struct node *)malloc(sizeof(struct node));
     printf("Enter the data%d : ", i);
     scanf("%d", &amp;amp;newnode-&amp;gt;data);
     newnode-&amp;gt;next = 0;
     if(head == 0)
     {
        head = temp = newnode;
     } 
     else
       { 
        temp-&amp;gt;next = newnode;
        temp = newnode;
       }
    }
   printf("--------------------------------\n");
   printf("Linked list : ");
   displayLL(head);
   small(head);
   large(head);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>linkedlist</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Macro Vs Function</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Mon, 27 Jun 2022 07:38:03 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/macro-vs-function-39cj</link>
      <guid>https://dev.to/dhanashreerugi/macro-vs-function-39cj</guid>
      <description>&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Macro&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Function&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;It is a fragment of code  given a name &lt;strong&gt;macro&lt;/strong&gt; and is defined by the preprocessor directive &lt;strong&gt;#define&lt;/strong&gt;. In the program before compilation, the macro  is replaced by its macro value (or text).&lt;/td&gt;
&lt;td&gt;It is a set of instructions enclosed within a flower &lt;strong&gt;({})&lt;/strong&gt; bracket. When a &lt;strong&gt;function&lt;/strong&gt; is called, it performs the specific task and returns to the main program.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It is preprocessed.&lt;/td&gt;
&lt;td&gt;It is compiled.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Macros&lt;/strong&gt; makes the code lengthy if its value is large because &lt;strong&gt;macros&lt;/strong&gt; will be replaced with its value before compilation.&lt;/td&gt;
&lt;td&gt;The repeated call to function does not affect the code length as it is written only once.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The program execution time remains unaffected using &lt;strong&gt;macro&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Here, the passing of parameters and returning of values takes some time and hence the program execution becomes slow.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In a program, if the &lt;strong&gt;macro&lt;/strong&gt; is appearing at multiple places then it is always a better idea to change that &lt;strong&gt;macro&lt;/strong&gt; into a &lt;strong&gt;function&lt;/strong&gt; because &lt;strong&gt;macros&lt;/strong&gt; will be replaced with its value which causes more memory consumption.&lt;/td&gt;
&lt;td&gt;In a program, calling the same &lt;strong&gt;function&lt;/strong&gt; repeatedly does not affect the memory consumption.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No type checking (like incompatible data type, operand etc.) is done during preprocessing hence more prone to error.&lt;/td&gt;
&lt;td&gt;Type checking is done during compilation.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;If you find any comparison other than these then please do suggest.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>c</category>
      <category>macro</category>
      <category>function</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Puzzle-4</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Fri, 24 Jun 2022 12:13:38 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/puzzle-4-3lck</link>
      <guid>https://dev.to/dhanashreerugi/puzzle-4-3lck</guid>
      <description>&lt;h2&gt;
  
  
  Can you guess the output without the help of code editor ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Comment the output in the below comment section.&lt;/strong&gt;&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 func(struct tag v);
int main()
{
    struct tag
    {
        int i;
        char c;
    };
    struct tag var = {2, 'd'};
    func(var);
}

void func(struct tag v)
{
    printf("%d\n %c", v.i, v.c);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Puzzle-3</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Wed, 22 Jun 2022 12:39:11 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/puzzle-3-4fn9</link>
      <guid>https://dev.to/dhanashreerugi/puzzle-3-4fn9</guid>
      <description>&lt;h2&gt;
  
  
  Can you guess the output without the help of code editor ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Comment the output in the below comment section.&lt;/strong&gt;&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;
struct student {char name[20]; int age;};
int main()
{
    struct student stu1 = {"anita", 10}, stu2 = {"anita", 20};
    if(stu1 == stu2)
       printf("Same");
    else
       printf("Not same");
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Puzzle-2</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Mon, 20 Jun 2022 09:36:11 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/puzzle-2-1fj4</link>
      <guid>https://dev.to/dhanashreerugi/puzzle-2-1fj4</guid>
      <description>&lt;h2&gt;
  
  
  Can you guess the output without the help of code editor ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;If yes, then comment the output in the below comment section.&lt;/strong&gt;&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;
struct res
{
    char *name;
    int age;
}*ptr;

int main()
{
    char name[100] = "Dhanashree";
    ptr = (struct res *)malloc(sizeof(struct res));
    ptr-&amp;gt;name = name;
    ptr-&amp;gt;age = 28;
    printf("name = %s\n", ptr-&amp;gt;name);
    printf("age = %d", ptr-&amp;gt;age);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Puzzle-1</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Fri, 17 Jun 2022 09:19:58 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/puzzle-session-2p49</link>
      <guid>https://dev.to/dhanashreerugi/puzzle-session-2p49</guid>
      <description>&lt;h2&gt;
  
  
  Can you guess the output without the help of code editor ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;If yes, then comment the output in the below comment section.&lt;/strong&gt;&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;
struct result
{
    int marks;
    char grade;
};
int main()
{
    struct result a1, b1;
    a1.marks = 50; a1.grade = 'A';
    b1 = a1;
    printf("marks = %d\n", b1.marks);
    printf("grade = %c\n", b1.grade);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Remove Duplicates From Sorted Linked List.</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Thu, 16 Jun 2022 09:59:06 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/remove-duplicates-from-sorted-linked-list-5g4k</link>
      <guid>https://dev.to/dhanashreerugi/remove-duplicates-from-sorted-linked-list-5g4k</guid>
      <description>&lt;p&gt;Suppose you are given a sorted linked list, you need to traverse a linked list, remove the duplicates from the list if exists and then print the resultant sorted linked list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1 :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Input : Linked List : 1, 2, 2, 3, 3, 4, 5&lt;br&gt;
Output : Linked List after removing duplicates : 1, 2, 3, 4, 5&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2 :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Input : Linked List : 5, 5, 6, 7, 8, 8&lt;br&gt;
Output : Linked List after removing duplicates : 5, 6, 7, 8&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Declare two pointers &lt;code&gt;currentNode&lt;/code&gt; and &lt;code&gt;nextNode&lt;/code&gt; of type &lt;code&gt;struct  node&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make &lt;code&gt;currentNode&lt;/code&gt; to point the &lt;code&gt;head&lt;/code&gt; node of the linked list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep iterating through the linked list until last node is reached. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare the data of current node with the data of next node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If they are equal, then detach one of the node(which is considered as duplicate) from the list by saving its neighbour node's address into pointer &lt;code&gt;nextNode&lt;/code&gt; i.e., &lt;code&gt;nextNode = currentNode-&amp;gt;next-&amp;gt;next&lt;/code&gt;. Then break the link between current node and the duplicate node and attach the current node to the node pointing to by pointer  &lt;code&gt;nextNode&lt;/code&gt; i.e.,  &lt;code&gt;currentNode-&amp;gt;next = nextNode&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If not, then continue traversing the linked list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, print the linked list.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  C program that removes the duplicates from sorted linked list :
&lt;/h2&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; 

struct node
{
    int data;
    struct node * next;
};

void displayLL(struct node * head)
{
    struct node * temp;
    temp = head;
    temp=head;
    while(temp!=0)
    {
       printf("%d ",temp-&amp;gt;data);
       temp = temp-&amp;gt;next;
    }
}

void removeDup(struct node *head)
{
    struct node *currentNode = head;
    struct node *nextNode;

    while(currentNode != NULL &amp;amp;&amp;amp; currentNode-&amp;gt;next != NULL)
  {
       if(currentNode-&amp;gt;data == currentNode-&amp;gt;next-&amp;gt;data )
       {   
           nextNode = currentNode-&amp;gt;next-&amp;gt;next;
        if(nextNode == NULL)
           {
             currentNode-&amp;gt;next = NULL;
             break;
           }
           currentNode-&amp;gt;next = nextNode;
       }   
       if(currentNode-&amp;gt;data != currentNode-&amp;gt;next-&amp;gt;data)
       {
           currentNode = currentNode-&amp;gt;next;
       }
   }
    printf("\n--------------------------------\n");
    printf("Linked List after removing duplicates : ");
    displayLL(head);
}

int main()
{
   struct node *head = 0, *newnode, *temp; 
   int n, choice, newdata;

// Create Linked List // 

   printf("Enter the number of nodes in the list : ");
   scanf("%d", &amp;amp;n);
   for(int i = 1; i&amp;lt;=n; i++)
   {
     newnode = (struct node *)malloc(sizeof(struct node));
     printf("Enter the data%d : ", i);
     scanf("%d", &amp;amp;newnode-&amp;gt;data);
     newnode-&amp;gt;next = 0;
     if(head == 0)
     {
        head = temp = newnode;
     } 
     else
       { 
        temp-&amp;gt;next = newnode;
        temp = newnode;
       }
    }
   printf("--------------------------------\n");
   printf("Linked list : ");

   displayLL(head);
   removeDup(head);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For more detail watch this &lt;a href="https://www.youtube.com/watch?v=U6ZbrYQVYzA"&gt;video&lt;/a&gt;.
&lt;/h3&gt;

</description>
      <category>c</category>
      <category>linkedlist</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Occurrence of a Number in a Linked List.</title>
      <dc:creator>Dhanashree Rugi</dc:creator>
      <pubDate>Tue, 14 Jun 2022 10:37:21 +0000</pubDate>
      <link>https://dev.to/dhanashreerugi/occurrence-of-a-number-in-a-linked-list-42e0</link>
      <guid>https://dev.to/dhanashreerugi/occurrence-of-a-number-in-a-linked-list-42e0</guid>
      <description>&lt;p&gt;Let us write a function that prints the number of times a number has occurred in a given linked list. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1 :&lt;/strong&gt;      &lt;/p&gt;

&lt;p&gt;Linked list : 2 6 4 4 5&lt;br&gt;
Occurrence of number &lt;code&gt;4&lt;/code&gt; : 2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2 :&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Linked list : 3 5 2 7 1 9&lt;br&gt;
Occurrence of number  &lt;code&gt;8&lt;/code&gt; : 0&lt;/p&gt;
&lt;h2&gt;
  
  
  Steps :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Declare an integer variable &lt;code&gt;item&lt;/code&gt; to store a number  whose occurrence has to be found.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initialise an another integer variable &lt;code&gt;count&lt;/code&gt; with &lt;code&gt;zero(0)&lt;/code&gt; to store the number of times a number has occurred i.e., &lt;code&gt;count = 0&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Declare a temporary pointer &lt;code&gt;temp&lt;/code&gt; of type &lt;code&gt;struct node&lt;/code&gt; for traversing a linked list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Take the input(a number whose occurrence is to be found) from the user and initialise that user input to variable &lt;code&gt;item&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start traversing a linked list until a number equal  to &lt;code&gt;item&lt;/code&gt; is   found. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a number equal to the &lt;code&gt;item&lt;/code&gt; is found , then update count by &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After reaching the end of linked list, print &lt;code&gt;count&lt;/code&gt; and exit the function.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;C program that finds the occurrence of number in a given linked list.&lt;/strong&gt;&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; 

struct node
{
   int data;
   struct node * next;
};  

void displayLL(struct node * head)
{
   int num = 0;
   struct node * temp;
   temp = head;
   temp=head;
   while(temp!=0)
   {
       printf("%d ",temp-&amp;gt;data);
       temp = temp-&amp;gt;next;
       num++;
   }
}

void occurrence(struct node *head)
{
   struct node *temp = head;
   int item, count = 0;
   printf("\nEnter the number whose occurrence is to find : ");
   scanf("%d", &amp;amp;item);

   while(temp != NULL)
   {
       if(temp-&amp;gt;data == item)
           count++;
           temp = temp-&amp;gt;next;
   }
   printf("Occurrence of number  %d : %d", item, count);
}

int main()
{
   struct node *head = 0, *newnode, *temp, *slow; 
   int n, choice, newdata;

// Create Linked List //

   printf("Enter the number of nodes in the list : ");
   scanf("%d", &amp;amp;n);
   for(int i = 1; i&amp;lt;=n; i++)
   {
   newnode = (struct node *)malloc(sizeof(struct node));
   printf("Enter the data%d : ", i);
   scanf("%d", &amp;amp;newnode-&amp;gt;data);
   newnode-&amp;gt;next = 0;
   if(head == 0)
    {
        head = temp = newnode;
    } 
    else
       { 
        temp-&amp;gt;next = newnode;
        temp = newnode;
       }
 }
   printf("--------------------------------\n");
   printf("Linked list : ");
   displayLL(head);
   occurrence(head);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;I own a website &lt;a href="http://www.coderlogs.com"&gt;www.coderlogs.com&lt;/a&gt; where in I write similar blogs so do visit the website for more such blog posts.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>c</category>
      <category>linkedlist</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
