CPE 101 Lab 2
- The end of week two; Friday 5:00pm
- You must turn in your work electronically on unix1 using the
handin command; instructions are provided below.
- Familiarization with the Unix programming environment and
- To write a complete C program given the problem specification.
- To learn the syntax of sequential C programs that interact
with a user.
Part 1 is an individual activity. The remainder of the lab is
to be completed with a partner. You must work together to
complete the activity, but each must record their own lab notes in
their notebook. You will submit just one completed program;
put both your names as authors in the program header.
Part 1: The Unix Computing Environment
Unix is a powerful operating system that you will use in many CSc
classes so it's good to get familiar with it now. One big
benefit is that you can develop your software on Unix by connecting
remotely from any internet-connected computer. Thus you can
complete your assignments from almost any computer in the
world. You can take a quick vacation to Bermuda and write your
101 programs from an Internet cafe on the beach.
It is crucial that you master the basic Unix commands needed to
perform the programming tasks required in the course assignment.
Read the list of Required
Unix Skills and work the Sample Scenario included.
Practice these skills on your own outside of class until you can
complete the scenario in under ten minutes.
Complete the remainder of the lab with your assigned partner.
Part 2: Exploration - evalcoins.c
Follow all the directions in the exploration Evaluating Coins.
In this activity you will develop a complete C program that solves a
simple sequential problem, the Granny
Quilt Cost problem. Name the source code file "grannyquilt.c"
Part 3: Create a complete program
Follow the steps in the process for how
build a program.
Demonstrate your executing program to the instructor before doing
the handin process. Verify that both student names are
included in the source file.
Use the handin command below:
handin graderjd Lab02 grannyquilt.c
Part 4: Converting a FORTRAN program to C (optional)
If you found part 3 a little challenging, this section will give you
- It is not uncommon for a programmer to be assigned to convert
a program from one language to another. At first this
sounds daunting, but many languages use the same principles and
the differences are largely superficial.
- Study this FORTRAN program that
solves a simple engineering problem. With a little study
you should be able to make a pretty good guess at how it
works. You'll notice some differences in the format of the
read and print commands. FORTRAN uses the "REAL" keyword
instead of "float". Beyond that it is very similar to C,
Java, and other languages.
- A sample program execution looks like this (user input is
For data entry, salinity units are parts per thousand
temperature is degrees Fahrenheit (floating point).
Enter first observed salinity and temperature: 30
Enter second observed salinity and temperature: 35
Enter new salinity: 33
Interpolated freezing temperature: 28.80000
- You assignment is to convert the source code to a C
program. Name the file seawater.c.
- Compile and execute it with the same input data and verify it
produces the same results as the original program.
- Submit your source file to handin.
If you finish before the end of lab, complete the homework
programs for Chapter 2.