Question
If a function contains two return statements successively, the compiler will generate
warnings. Yes/No ?
Answer: Option A
#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 */
}
Was this answer helpful ?
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
Was this answer helpful ?
More Questions on This Topic :
Question 2.
Every function must return a value
....
Submit Solution