Functions

Q1: In a function two return statements should never occur

A Yes

B No

ANS:B - No

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



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.