![Advantech UbiQ Скачать руководство пользователя страница 58](http://html1.mh-extra.com/html/advantech/ubiq/ubiq_user-manual_2856809058.webp)
UbiQ Scenario Manager User Manual
52
y = f( x );
}
In this example, the statement y = x/i; is executed if i is greater than 0. If i is less than
or equal to 0, i is assigned to x and f( x ) is assigned to y. Note that the statement
forming the if clause ends with a semicolon.
return statement
The return statement terminates the execution of a function and returns control to the
calling function. Execution resumes in the calling function at the point immediately
following the call. A return statement can also return a value to the calling function.
Syntax
return-statement :
return(expression) ;
The value of expression, if present, is returned to the calling function. If expression is
omitted, the return value of the function is undefined. The expression, if present, is
converted to the type returned by the function. If the function was declared with return
type void, a return statement containing an expression generates a warning and the
expression is not evaluated.
If no return statement appears in a function definition, control automatically returns to
the calling function after the last statement of the called function is executed. In this
case, the return value of the called function is undefined. If a return value is not
required, declare the function to have void return type; otherwise, the default return
type is int.
This example demonstrates the return statement:
int sum( int num );
int main()
{
int nSum;
nSum=sum(100);
printf(°×The sum(100)=%d°±,nSum);
}
/* Sum the values between 0 and num. */
sum(int num)
{
int running_sum;
running_sum = 0;
while(num>0) {
running_sum = runni num;
num = num - 1;
Содержание UbiQ
Страница 1: ...User Manual UbiQ Scenario Manager User Manual V1 03...
Страница 4: ...UbiQ Scenario Manager User Manual iv...
Страница 7: ...Chapter 1 1 Introduction...
Страница 13: ...Chapter 2 2 Getting Started...
Страница 37: ...Chapter 3 3 Tutorials...
Страница 47: ...Chapter 4 4 Basic of Smart C Script Language...
Страница 62: ...UbiQ Scenario Manager User Manual 56...
Страница 63: ...Chapter 5 5 Functions Reference...