title: To count the number of characters in a 2-Dimensional String
body: <p><strong>Practice.c</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
    char str[][30]={
                     "My name is Abcd Efgh Jklm.",
                     "I Graduated from BIT.",
                     "I now live in Balochistan."
                   };
    int strcount=sizeof(str)/sizeof(str[0]);
    int i=0;
    int count=0;         
  
    for(;i&lt;strcount;++i)
    {
      while(str[i][count] != '\0')
        ++count;
  
      printf("\n\nNumber of Characters in STR[%d] = %d",i,count);
    }
  
    return 0;
  }
  </code></pre>
  
  <p><strong>Output of the above stated program is as follows:</strong></p>
  
  <pre><code>Number of Characters in STR[0] = 26
  
  Number of Characters in STR[1] = 26
  
  Number of Characters in STR[2] = 26
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>Test.c</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
    char str[][30]={
                     "My name is Abcd Efgh Jklm.",
                     "I Graduated from BIT.",
                     "I now live in Balochistan."
                   };
    int strcount=sizeof(str)/sizeof(str[0]);
    int i=0;         
  
    for(;i&lt;strcount;++i)
    {
      int count=0;
      while(str[i][count] != '\0')
        ++count;
  
      printf("\n\nNumber of Characters in STR[%d] = %d",i,count);
    }
  
    return 0;
  }
  </code></pre>
  
  <p><strong>Output of the above stated program is as follow:</strong></p>
  
  <pre><code>Number of Characters in STR[0] = 26
  
  Number of Characters in STR[1] = 21
  
  Number of Characters in STR[2] = 26
  </code></pre>
  
  <p><br/></p>
  
  <p>I made a little modification in the program <code>Test.c</code> by changing the position of variable <code>count</code>,and placed it in the <code>for loop</code>, the output was as desired. 
  I recon that this behavior of <code>count</code> is due to its position, means where it is declared (inside the <code>for loop</code> or outside).</p>
  
  <p><strong>My question:</strong><br>
  1]Why <code>count</code>, when placed outside the <code>for loop</code> displays <code>26</code> as the output for all?</p>