title: Sum of array in C by user input
body: <p>i have wrote a program to sum int array but i want if one input is string(character) then the program will give error &quot;You Must Enter Int value&quot;.</p>
  <p>my following code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  
   int main()
      {
  int a[1000],i,n,sum=0;
      
  
  printf(&quot;Enter size of the array : &quot;);
  scanf(&quot;%d&quot;,&amp;n);
  printf(&quot;Enter elements in array : &quot;);
  for(i=0; i&lt;n; i++)
  {
      scanf(&quot;%d&quot;,&amp;a[i]);
  }
  
  for(i=0; i&lt;n; i++)
  {
       
      sum+=a[i];
  }
  
      printf(&quot;sum of array is : %d&quot;,sum);     
  
           return 0;
        }
  </code></pre>