user11873: When I try to compile the following code in Arduino ,I get the error "expected initializer before 'void'".How can I get the code to work?
  void setup() {  
  Serial.begin(9600);
}

float area = 0.0f,pre_area = 0.0f,tarea = 0.0f,rarea = 0.0f;
int x = 0,pre_x = 0,t = 0,pre_t = 0;


long unsigned int t


void loop()
{
  x = analogRead(A0);
  t = millis();
  float diff_t = (float)(t - pre_t)/1000.0f;
  area = (0.5 * (pre_x + x) * diff_t) + pre_area;

  Serial.print(area);
  analogWrite(DAC0, area);
  pre_x = x;
  pre_area = area;
  pre_time = t;
}


user4143: You add the semicolon that is missing at the end of long unsigned int t

user11754: Why have you written t = 0 here and declared it again below??
int x = 0,pre_x = 0,t = 0,pre_t = 0;

Semi Colon Missing 
long unsigned int t;

Where have you declared pre_time??
  pre_time = t;


11873: <p>When I try to compile the following code in Arduino ,I get the error "expected initializer before 'void'".How can I get the code to work?</p>

<pre><code>  void setup() {  
  Serial.begin(9600);
}

float area = 0.0f,pre_area = 0.0f,tarea = 0.0f,rarea = 0.0f;
int x = 0,pre_x = 0,t = 0,pre_t = 0;


long unsigned int t


void loop()
{
  x = analogRead(A0);
  t = millis();
  float diff_t = (float)(t - pre_t)/1000.0f;
  area = (0.5 * (pre_x + x) * diff_t) + pre_area;

  Serial.print(area);
  analogWrite(DAC0, area);
  pre_x = x;
  pre_area = area;
  pre_time = t;
}
</code></pre>
 4143: <p>You add the semicolon that is missing at the end of <code>long unsigned int t</code></p>
 11754: <p><strong>Why have you written t = 0 here and declared it again below??</strong></p>

<pre><code>int x = 0,pre_x = 0,t = 0,pre_t = 0;
</code></pre>

<p><strong>Semi Colon Missing</strong>    </p>

<pre><code>long unsigned int t;
</code></pre>

<p><strong>Where have you declared pre_time??</strong></p>

<pre><code>  pre_time = t;
</code></pre>
