Sail E0 Webinar
Question

In a function two return statements should never occur.


Options:
A .  Yes
B .  No
Answer: Option B


No, In a function two return statements can occur but not successively.
Example:


#include<stdio.h>
int mul(int, int); /* Function prototype */
int main()
{
int a = 0, b = 3, c;
c = mul(a, b);
printf("c = %d\n", c);
return 0;
}
/* Two return statements in the mul() function */
int mul(int a, int b)
{
if(a == 0 || b == 0)
{
return 0;
}
else
{
return (a * b);
}
}


Output:
c = 0



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers