Expected initializer before void in function......

When I try to compile the following code in Arduino 0015,I get the error "Expected initializer before void in function void loop()".How can I get the code to work?

byte myvar
void setup()
{
  myvar = 10
  Serial.begin (9600);
 }
void loop()
 {
   if (10 == HIGH)
   {
     Serial.println (myvar);
    }
   }

You need to have a semicolon at the end of each expression.

byte myvar;  // semicolon needed here
void setup()
{
  myvar = 10;   // and here
    Serial.begin (9600);
}
void loop()
{
  if (10 == HIGH)  
  {
    Serial.println (myvar);
  }
}

This code will compile but wont print anything because if (10 == HIGH) will never be true, what did you want to do here?

Thanks.By 10 I meant for it to be pin 10,oops forgot to define the input.

Arduino digital pins are inputs by default, although it does no harm to explicitly declare inputs in setup.

Your loop code could look like this:

void loop() { if (digitalRead(10) == HIGH) { Serial.println (myvar); delay(100); // add a delay to reduce the number of times this prints. } }

ok,thanks