Consider the program given below, written using the top-down approach, that calculates the factorial of a given integer number using function fact defined in Example. Function fact is called in the main function from a printf function call and the int value returned by it is printed using the %d conversion specification.
Observe that the main function is defined first followed by the function fact, which is called before it is defined. Thus, we need to declare fact in the main function or before it. In the program given above, fact is declared before the main function. The program output is given below.
printf("Enter any Number : ");
printf("Factorial of %d is : %d",n,t);
int fact(int a)