1.

Explain Return statement with example.

Answer»

Return Statement: The keyword return is used to terminate function and return a value to its caller. The return statement may also be used to exit a function without returning a value. The return statement may or may not include an expression.
Example Program:

# include<stdio.h>
void main (void)
{
float max (float, float, float);
float a, b, c maximum;
printf (“Enter three numbers\n”);
scanf (“%d %d %d”, &a, &b &c);
maximum = max (a, b, c);
printf(“maximum = %d, maximum);
}
float max (float x, float y, float z)
}
if (x > y)
{
if (x > z)
return (x);
}
else
{
if (y > z)
return (z);
else
return (z);
}
}

Output:
Enter three numbers
2 4 8
maximum = 8



Discussion

No Comment Found