the programmer is free to use it before the closing brace of the function body.
For example,
#include
void main( )
{
void test( );
test( );
}
void test( )
{
int u;
printf(“Enter your number: “);
scanf(%d”, &u);
if ( u < 0)
{
printf(“\n It is a negative number”);
return;
}
else
{
printf(”\n It is a positive number”);
return;
}
}
OUTPUT (after running):
Enter your number: -80
It is a negative number
NOTE
If you call a value-returning function and use it in a context in which no value is
expected, say, you are not assigning the return value to anything, actually nothing
unusual happens. There is no warning message by the compiler. The function executes
correctly and it returns its value. The caller function can use it or ignore it.
Do'stlaringiz bilan baham: |