# Files in C-programming, factorial

1. Files can be used to store data. There is a function called feof() in standard C library to detect end of file condition. Assume that the input file contains simplified census data; each line contains a record and each record has name, sex, and age in a specific city. Write the pseudocode to find % of males, % of females, % of children (i.e. <17 years old), % of adults (ages 18 to 54), and % of elderly citizens (ages 55 and above).

2. Assuming that n is an integer argument, write a function to compute factorial(n) where

factorial(n) = 1, when n = 1

= factorial(n-1) * n if n > 1

https://brainmass.com/computer-science/c/files-in-c-programming-factorial-94821

#### Solution Preview

You can use any of the:

int factorial (int n) ;

int factorial1 (int n) ;

functions.

However, recursive version:

int factorial1 (int n) ;

is not memory efficient.

Use

int factorial (int n) ;

for efficient ...