CS201
Lab 4 - Simple C Selection
Objectives:
- Solve a selection problem using a C program.
Readings:
- Read Chapter 4 in the Hanly/Koffman text.
Deliverables: (DUE BY END OF LAB!)
- Submittal of your ALGORITHM designed to solve the problem.
- Submittal of your lab4.c and Makefile
files.
- Your program needs to match the algorithm you submitted.
TO DO (for today's lab)
- Design an ALGORITHM to solve Programming Project #6
on page 205 of the Hanly/Koffman text.
- Whenever designing your solution, consider that the likelihood of having the
coordinate values as input are as follows:
Q1>Q2>Q4>Q3
- Write a C program following your algorithm (i.e. implement your design in
C).
- Make sure that your IMPLEMENTATION is matching your ALGORITHM (order of
statements, etc.).
- Use redirection to enter your x y coordinate pair.
Do not prompt for these values, just read them in from a data
file using
scanf as you did the last time.
- For your input data file build a short file with two
floats in the first line. (Assume all numbers have one
decimal place precision.)
Suppose you wanted to enter an x, y of
3.0 -3.2. You would
build a file that had the following numbers in line one.
3.0 -3.2
Call this file datain4 and save it to your directory.
- A sample run of your program assuming "lab4" for the name of
your
run image would look like the following:
$ lab4 < datain4
- A sample output would look like the following:
(bbb3.0,bb-3.2) is in
quadrant
IV
- Some other possible outputs for various numbers follows:
(bbb3.0,bbb0.0) is
on the x axis
-
(bb-0.0,bbb0.0) is on the origin
(bb-2.5,bbb1.9) is in
quadrant II
- The automatic submittal script will expect your output to
be formatted exactly as shown above. The b's are
blanks.
- You do not need to submit your sample data file. I will provide
a set of test data files for the automatic script to use to
test your program.
LAB 4 ENRICHMENT
- Analyze the Code, Compile, Run and Analyze the Results for the following
programs: