FUNCTIONS
Returning functions - are functions that returns value.void setup()
{
Serial.begin(9600);
}
void loop()
{
double x=5, y=6;
Serial.print( Product( x, y ) ) ;
}
float Product(int a, int b)
{
int y = a * b;
return y;
}
Generate a result in the serial terminal
30.00
30.00
30.00
30.00
.
.
.
30.00
and so on....
Non returning function - are functions that does'nt returns a value, also called as "void" function
int jj;
void setup()
{
Serial.begin(9600);
}
void loop()
{
double x=5, y=6;
Product( x, y ) ;
Serial.println( jj );
}
float Product(int a, int b)
{
jj = a * b;
}
Generate a result in the serial terminal
30.00
30.00
30.00
30.00
.
.
.
30.00
and so on....
In a non-returning function any calculated results/values that are process inside that function are stored in a global variable. Hence...you will need a global variable (i.e. "jj" in this example) to make use of the result made by the called function.