title: printing common characters in three strings
body: <p>Q)  Write a c program that takes as input three strings, each of maximum 30 characters, and
  prints common characters present in all three strings. Each string can have different number of
  characters.</p>
  
  <p>The code i have written is:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      int c1=0 , c2=0, c3=0 ,i,x;  
      int count1[26]={0} , count2[26]={0} , count3[26]={0};  
      char st1[30],st2[30],st3[30];  
      printf("enter string1: ");  
      gets(st1);  
      printf("\n enter string2: ");  
      gets(st2);  
      printf("\n enter string3: ");
      gets(st3); 
  
      while(st1[c1]!='\0')  
      {
          count1[st1[c1]-'a']++;  
          c1++;
      } 
  
      while(st2[c2]!='\0')    
      {
          count2[st2[c2]-'a']++;   
          c2++;
      }
  
      while(st3[c3]!='\0')
      {
          count3[st3[c3]-'a']++;
          c3++;
      }
  
      for(i=0;i&lt;26;i++)
      {
          if(count1[i]!=0 &amp;&amp; count2[i]!=0 &amp;&amp; count3[i]!=0)
          {
              if (count1[i]&lt;count2[i] &amp;&amp; count1[i]&lt;count3[i])
              {
                  for(x=0;x&lt;count1;x++)
                  {
                      printf("\n %c ",x+'a');
                  }
              }
              else if(count2[i]&lt; count1[i] &amp;&amp; count2[i]&lt; count3[i])
              {
                  for(x=0;x&lt;count2;x++)
                  {
                      printf("%c",x+'a');
                  }
              }
              else
              {
                  for(x=0;x&lt;count3;x++)
                  {
                      printf("%c",x+'a');
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>But when i run the code in codeblocks,continuous randomcharacters are occuring with continous beep beep sound till i shut down the system. can anyone help me with this?</p>