A function can return more than one value? True-false?
Answers
Answer:
No, we can't return more than one value at a time using functions in
C, bcz calling function holds only one return value from called
function at a time.
Explanation:
Example:-
int d=dispo: - calling function
int dispo --> called function
int a=10,b=-40,c=D;
return(a);
return(b);
return(c);
/* return(a,b,c) * --> syntax not possible
It gives error.
In the above example compiler will get ambiguity(confusion), which
value need to return like that. Hence it returns only one value at a
time.
Even though if we use multiple return statements depends upon
situation it returns only one value at a time.
Example:
int d=disp(10);
int disp(int n)
if(n>0)
printf("value is positive");
return(n);
else if(n=0)
printf("value if negative");
return(n);
else
printf("value is zero"):
return(n);
It doesn't give any error but it returns only one value at a time
Answer:
A function can return more than one value. true and false