Instructions
178Compiler
© 2013 Conrad Electronic
// x,y not accessable since local to function func1
}
Global variables have a defined memory space which is available throughout the entire program run.
At program start the global variables will be initialized by zero. Local Variables get not initialized
at the begin of a function!
Local variables will during calculation of a function be arranged on the stack. I. e. local variables ex-
ist in memory only during the time period in which the function is executed.
If with local variables the same name is selected as with a global variable then the local variable will
conceal the global variable. While the program is working in the function where the identically named
variable has been defined the global variable cannot be addressed.
Static Variables
With local variables the property static can be placed for the data type.
void func1(void)
{
static int a;
}
In opposition to normal local variables will static variables still keep their value even if the function is
left. At a further call-up of the function the static variable will have the same contents as when leaving
the function. In order to have the contents of a static variable defined at first access the static vari-
ables will equally to global variables at program start also be initialized by zero.
4.2.5 Operators
Priorities of Operators
Operators separate arithmetic expressions into partial expressions. The operators are then evaluated
in the succession of their priorities (precedence). Expressions with operators of identical precedence
will be calculated from left to right.
Example:
i= 2+3*4-5; // result 9 => first 3*4, then +2, finally -5
The succession of the execution can be influenced by setting of parenthesis. Parenthesis have the
highest priority.
If the last example should strictly be calculated from left to right, then:
i= (2+3)*4-5; // result 15 => first 2+3, then *4, finally -5
A list of priorities can be found in Precedence Table.