Functions

Q1:
If a function contains two return statements successively, the compiler will generate warnings. Yes/No ?

A Yes

B No

ANS:A - Yes

Yes. If a function contains two return statements successively, the compiler will generate "Unreachable code" warnings. Example:


#include<stdio.h>
int mul(int, int); /* Function prototype */

int main()
{
    int a = 4, b = 3, c;
    c = mul(a, b);
    printf("c = %d\n", c);
    return 0;
}
int mul(int a, int b)
{
   return (a * b);
   return (a - b); /* Warning: Unreachable code */
}
Output:
c = 12



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.