top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

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

–3 votes
87 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...