title: How to calculate phase shift between two shifted wave signals in C
body: <p>I'm comparing two different phase shifted wave signals with same frequency, my first task is to measure phase shift angle between two signals in <strong>C language</strong>.
  Actually i'm from IC field and don't have much idea about programming language, but i'm currently learning C for that.  </p>
  
  <p>I'd write a code for Correlation Co-efficient for finding a time delay.
  but its shows an error.
  <a href="https://i.stack.imgur.com/Yj3E6.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdbool.h&gt;
  #include &lt;math.h&gt;
  int main()
  {
      bool True  =  1; //for sqr wave conversion
      bool False =  0 ;
      int n[10],m[10] ; // n is an array of 10 integers (as of now assuming some value)
      int i1, i2,x,y ;
      int r,xx[10],xy[10],yy[10],nr=0,dr_1=0,dr_2=0,dr_3=0,dr=0;
      int sum_y=0,sum_yy=0,sum_xy=0,sum_x=0,sum_xx=0;
      int  i, h=10;
  
  
      /* initialize elements1 of array n to 0 */
      for (i1=0;i1&lt;10;i1++)
      {
          n[i1] = i1+1; // set an element at location i to 10
      }
       /* initialize elements2 of array n to 0 */
      for (i2=0; i2&lt;10; i2++)
      {
          m[i2] = i2+5;
  
      }
  
      //output of each array element
      for (x=0 ;x&lt;10; x++)
      {
               if (x%2 == 0) //sqr wave coversion
                {
           True = 1 ;
                 }
  
                else
                {
           False = 0 ;
                }
  
          printf("element1 [%d] = %d\n" , x, n[x]);
  
      }
      for (y=0 ; y&lt;10; y++)
      {
              if (y%2 == 0) //sqr wave
              {
               False  = 0;
              }
  
              else
  
              {
               True = 1;
              }
  
  
          printf("element2 [%d] = %d\n" , y, m[y]);
      }
      for(i=0; i&lt;h; i++)
      {
       xx[i]= x[i]*x[i];
       yy[i]= y[i]*y[i];
      }
       for(i=0;i&lt;h;i++)
      {
       sum_x+=x[i];
       sum_y+=y[i];
       sum_xx+= xx[i];
       sum_yy+=yy[i];
       sum_xy+= x[i]*y[i];
      }
      hr=(h*sum_xy)-(sum_x*sum_y);
      int sum_x2=sum_x*sum_x;
      int sum_y2=sum_y*sum_y;
      dr_1=(h*sum_xx)-sum_x2;
      dr_2=(h*sum_yy)-sum_y2;
      dr_3=dr_1*dr_2;
      dr=sqrt(dr_3);
      r=(hr/dr);
      printf("Total Numbers:%d\nCorrelation Coefficient:%.2f",h,r);
      return 0;
  }
  </code></pre>
  
  <p>Code is still incomplete for finding a phase angle , but as of now i'm facing this error.[added snapshot] </p>
  
  <p>PS: <strong>I'd already done this task on H/W platform.</strong></p>