<?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: 221910307028</title>
    <description>The latest articles on DEV Community by 221910307028 (@kjagadeeswar).</description>
    <link>https://dev.to/kjagadeeswar</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%2F761944%2F6b32fe46-f7f3-45a0-832c-580487994ad8.png</url>
      <title>DEV Community: 221910307028</title>
      <link>https://dev.to/kjagadeeswar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kjagadeeswar"/>
    <language>en</language>
    <item>
      <title>How to Know if two given strings are anagrams in C</title>
      <dc:creator>221910307028</dc:creator>
      <pubDate>Thu, 25 Nov 2021 10:54:46 +0000</pubDate>
      <link>https://dev.to/kjagadeeswar/how-to-know-if-two-given-strings-are-anagrams-in-c-oem</link>
      <guid>https://dev.to/kjagadeeswar/how-to-know-if-two-given-strings-are-anagrams-in-c-oem</guid>
      <description>&lt;h1&gt;
  
  
  What is an Anagram?
&lt;/h1&gt;

&lt;p&gt;An anagram is a word made by rearranging an original word’s letters to make a new word.&lt;/p&gt;

&lt;p&gt;For example, “listen” and “silent” are anagrams of each other because we can create them by rearranging the other’s letters. In other words, the strings contain the same letters, but in a different order.&lt;/p&gt;

&lt;h1&gt;
  
  
  Code
&lt;/h1&gt;

&lt;p&gt;We are using the sorting method in the C program below to figure out if two strings are anagrams:&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;string.h&amp;gt;

      void main () 
      {
         char s1[] = "listen";
         char s2[] = "silent";
         char t;
         int i, j;
         int n  = strlen(s1);
         int n1 = strlen(s2);

         // If both strings are of different length, then we can directly say they are not anagrams
         if( n != n1) 
         {    
            printf("%s and %s are not anagrams! \n", s1, s2);
         }

         // Soring both strings −

          for (i = 0; i &amp;lt; n-1; i++) 
         {
            for (j = i+1; j &amp;lt; n; j++) 
            {
               if (s1[i] &amp;gt; s1[j]) 
               {
                  t = s1[i];
                  s1[i] = s1[j];
                  s1[j] = t;
               }
               if (s2[i] &amp;gt; s2[j]) 
               {
                  t = s2[i];
                  s2[i] = s2[j];
                  s2[j] = t;
               }
           }
        }

         // Compare both strings character by character

          for(i = 0; i&amp;lt;n; i++) 
         {
            if(s1[i] != s2[i]) 
            {    
               printf("Given strings are not anagrams\n");
            }
         }
         printf("Given strings are anagrams!\n");
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>anagrams</category>
    </item>
  </channel>
</rss>
