Using multiple return statements in a function. - C Function

C examples for Function:Function Return

Description

Using multiple return statements in a function.

Demo Code

#include <stdio.h>

int x, y, z;/*from   w ww  . j  a v  a  2 s. c o  m*/

int larger_of( int a, int b);

int main( void )
{
    puts("Enter two different integer values: ");
    scanf("%d%d", &x, &y);

    z = larger_of(x,y);

    printf("\nThe larger value is %d.", z);

   return 0;
}

int larger_of( int a, int b)
{
    if (a > b)
        return a;
    else
        return b;
}

Related Tutorials