CS201
Lab 3 - Simple C Functions
Objectives:
- Solve a problem using a C Functions, Top-Down Design philosophy and
proper Coding Conventions .
Readings:
Deliverables: (DUE BY THE END OF THE LAB!)
- Submittal of your lab3.c and Makefile files.
TO DO (for today's lab)
- Design and Write a program to solve Programming Project #5
on page 142 of the Hanly/Koffman text. Use at least two functions wen creating
your solution (one must be named: twoDecimalRnd,
and another one: printMyResults)
- Use redirection to enter your positive number with
a fractional part. Do not prompt for these values, just read them in from a data file
using
scanf.
- For your input, build a short data file (call it
datain3) that includes only one float
in the first line.
Suppose you wanted to enter 1.449. You would
build a file datain3 that had the following number in line one.
1.449
Make sure to call this file "datain3" and save it to your directory.
- A sample run of your program assuming "lab3" for the name of your
run image would look like the following:
$ lab3 < datain3
- A sample output would look like the following:
bbb1.449 rounded =bbbb1.450
(The b's are blanks)
- The automatic submittal script will expect your output to
be formatted exactly as shown above.
- 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.
- Make sure to comment your code properly! Including the functions!
- Follow proper Coding Conventions when programming.
LAB 3 ENRICHMENT
- Create a flowchart reflecting the algorithm you designed to complete the
assignment.
- Find out what functions are available via math.h
library.