Purchase Solution

Files in C-programming, factorial

Not what you're looking for?

Ask Custom Question

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

Attachments
Purchase this Solution

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 ...

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.