in Programming in C
263 views
0 votes
0 votes

What happens if there are more than 1 return statements in a function?

in Programming in C
263 views

1 Answer

3 votes
3 votes
Best answer

only first return will get executed .After which the control will be transferd back

#include<stdio.h>

int fun()
{
return 5+2;
return 5-1;
}

int main() {

    printf("%d ", fun());
	return 0;
}

Here output will be 7 . The will execute successfully witout any error

selected by