top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to write two return statement in a c program in same function?

–3 votes
384 views
How to write two return statement in a c program in same function?
posted Sep 11, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
The short answer is no you can not return twice from one function. However if you want to return something in one flow and something in other flow then use the example or something similar what Double S has suggested.
In your question you have not specify, how you want to return, i.e without any condition or with some condition.
Without any condition you can't return twice, if you have some if, else if, switch cases then you can return as number as of conditions.

1 Answer

+2 votes
int EvenOdd(int number)
{
       if(number%2 == 0)
            return 0;
       else
            return 1;
}
answer Sep 11, 2014 by Double S
...