title: How to remove the last comma in comma separated prime numbers within a range?
body: <p>I have the code for finding prime numbers within a range.</p>
  
  <p>The problem is to remove the last comma.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      int a,b,i,x,c,f=1;
      scanf("%d%d",&amp;a,&amp;b);
      for(x=a;x&lt;=b;(x++,f=0))
      {
  
          for(i=2;i&lt;x;i++)
          {
              if(x%i==0)
              {
                   f=1;
              }
          }
  
          if(f==0)
              printf("%d,",x);
       }
    }
  </code></pre>
  
  <p>But the output contains an extra comma in the last.
  For example </p>
  
  <blockquote>
    <p>2,3,5,7,</p>
  </blockquote>
  
  <p>whereas the expected output is </p>
  
  <blockquote>
    <p>2,3,5,7</p>
  </blockquote>