I need to find the period of wave using zero crossings given a set of values that represents a sine wave...

I'm a little new to C so there is a chance I made this over complicated, but...

oh also, the time of the zero-crossing can be estimated as tz=(t1+t2)/2 and after finding the first two zero-crossings, twice the time difference between those points is the estimated period.

```
#include <stdio.h>
int main( void)
{
int s; // scanf return status
double d, y1, y2, tz, tz2, t1=0, t2=1;
while( 1) // until end-of-file or error
{
s = scanf("%lf",&d); // scans for given values
if( s != 1) // could not read one double, must be end-of-file or error
break;
y2=y1;
y1=d;
if (y1>0)// I have two possibilities y1>0 and y1<0
{
while (y2>0) //there would not be a zero crossing, so code would break out of loop
{
break;
}
while(y2<0){
tz=(t1+t2)/2;
printf("%g/n",tz);
break;} // gets the first tz value
else if (y2 != 0){
break;
}}}
if (y1<0)
{
while (y2<0)
{
break;
while(y2>0){
tz2=(t1+t2)/2;
printf("%g/n",tz2);
break;}
else if (y2 =! 0)
break;
}}}
t1++;
t2++;
printf("%g/n",(tz2-tz)/2);
return 0;
}
```