user40015: I don't have much experience in C++ programming. I'm getting this error
'z' does not name a type!!! 
which I have't seen in MATLAB or python... What's wrong??? It is so simple!!!
float x=10; float y=50; float z;
z=x*y;

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

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


user31105: 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:
}


40015: <p>I don't have much experience in C++ programming. I'm getting this error</p>

<p><code>'z' does not name a type!!!</code> </p>

<p>which I have't seen in MATLAB or python... What's wrong??? It is so simple!!!</p>

<pre><code>float x=10; float y=50; float z;
z=x*y;

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

void loop() {
  // put your main code here, to run repeatedly:
}
</code></pre>
 31105: <p>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).</p>

<p>Try the following:</p>

<pre><code>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:
}
</code></pre>

<p><strong>Update</strong></p>

<p>What even is easier and also works (thanks to Ruslan and Juraj):</p>

<pre><code>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:
}
</code></pre>
