![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
eramit2010
Add this condition to your program:
Close, but not quite:
Code:
$ cat prod.c
#include <stdio.h>
int even_prod(int num)
{
if(num!=0)
{
if (num%2 != 0)
return (even_prod(num-1));
else
return (num *(even_prod(num-2)));
}
}
int main()
{
printf("%d\n", even_prod(5));
return 0;
}
$ make prod
gcc -Wall -Wunreachable-code -ggdb3 -std=c99 -pedantic -lm -lpthread prod.c -o prod
prod.c: In function ‘even_prod’:
prod.c:11: warning: control reaches end of non-void function
You need to return something in the case that num is zero. Since it's a product function, the multiplicative identity (1) is a good choice.