Sams Teach Yourself C in 21 Days

(singke) #1

TYPE& RUN 2 Find the Number


This is the second Type & Run section. Remember, the purpose of the listings
in these sections is to give you something a little more functional than what you
are getting in the chapters. This listing contains elements not yet explained in
the book; however, we believe you will find the listing easy to follow. After you
type in and run this program, take the time to experiment with the code. Make
changes, recompile, and then rerun the program to see what happens. If you get
any errors, make sure you entered it correctly.

LISTINGT&R 2 find_nbr.c
1: /* Name: find_nbr.c
2: * Purpose: This program picks a random number and then
3: * lets the user try to guess it
4: * Returns: Nothing
5: */
6:
7: #include <stdio.h>
8: #include <stdlib.h>
9: #include <time.h>
10:
11: #define NO 0
12: #define YES 1

08 448201x-T&R2 8/13/02 11:20 AM Page 93

Free download pdf