title: How to iterate this sin equation?
body: <p>I can't create the correct file. the equation in the program doesn't iterate through and it only writes the same sum at as many samples as were requested.</p>
  
  <p>for loops.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  
  #define LEN 256
  
  int main ()
  {
     FILE * fp;
     double i=0; //sample count
     double y=0; //y values
     double f=0; //frequency
     double t=0; //time
  
     /* open the file for writing*/
     fp = fopen ("1.dat","w");
  //fprintf(fp, "sample #\ty-value\n"); 
  
  printf("Enter the frequency in hertz: ");
  scanf("%lg", &amp;f);
  printf("Enter the number of samples : ");
  scanf("%lg", &amp;t);
  
  
  
     /* write 1 seconds of time data into the file stream*/
     for(i = 0; i &lt; t;i++){
  
  //y=sin(i*M_PI/180);
  y=sin(2*M_PI*f*t);
  
  //       fprintf (fp, "%g  %g\n",i ,y);
         fprintf (fp, "%g\n",y);
     }
  
     /* close the file*/  
     fclose (fp);
     return 0;
  }
  </code></pre>