The exit statement would then terminate the program. To use it, you must include the file stdlib.h in the preamble of the program. The program asks the user to key in an integer. Thus the program checks for this type of data. If it occurs, a message to this effect is printed and the exit statement is used to terminate the program.
Factorials grow fast as n increases.
We need to terminate the program at the point where we exceed this threshold. The trick is to see it coming in advance. The loop then has two components. If the latter is expected to exceed the machine's capacity, the loop terminates with a break statement. Ask the user for a non-negative integer.