Вам нужно научиться отлаживать свой код. Хорошее начало - изменить fact
так:
int fact(int n) {
printf("a: %d count: %d fact0: %d n: %d\n", a, count, fact0, n);
if (n == count) {
printf("n is equal to count\n");
return fact0;//Only this return statement should be executed
}
fact0 = fact0 * a;
a++;
count++;
fact(n);
return 1;//But this return statement is executed , Why?
}
Тогда пробег будет выглядеть так:
$ ./a.out
Enter the factorial number
4
a: 2 count: 1 fact0: 1 n: 4
a: 3 count: 2 fact0: 2 n: 4
a: 4 count: 3 fact0: 6 n: 4
a: 5 count: 4 fact0: 24 n: 4
n is equal to count
The factorial of the number is 1
Это должно дать довольно хороший ключ к пониманию того, что происходит. При необходимости добавьте больше операторов печати.