Skip to main content
added 296 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 40
  • 58

You cannot put an expression statement outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}

Update

What even is easier and also works (thanks to Ruslan and Juraj):

float x=10; float y=50; float z=x*y;

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

You cannot put an expression statement outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}

You cannot put an expression statement outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}

Update

What even is easier and also works (thanks to Ruslan and Juraj):

float x=10; float y=50; float z=x*y;

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}
added 10 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 40
  • 58

You cannot put an expression statement outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}

You cannot put an expression outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}

You cannot put an expression statement outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}
Source Link
Michel Keijzers
  • 13k
  • 7
  • 40
  • 58

You cannot put an expression outside a function. Only the variable declarations can be placed outside functions (and those variables are called globals/global variables).

Try the following:

float x=10; float y=50; float z;


void setup() {
  // put your setup code here, to run once:
  z=x*y;
}

void loop() {
  // put your main code here, to run repeatedly:
}