Getting Started
Log into the computer science server and use
wget
and
tar
to download
your starter code.
- Use
wget
to download the file at http://cs.longwood.edu/courses/cmsc160/f17/files/lab4.tgz
- Uncompress the lab4.tgz file by using
tar -xvzf lab4.tgz
- Use
ls
to see that there is a new directory called lab4
- Use
cd lab4
to change directory to the lab4 directory
Linux Commands
We can create new files and directories but sometimes we need to move or delete our files.
rm filename
permanently removes (deletes) the file
cp oldname newname
copies the file at oldname to a new file at newname.
mv oldname newname
moves the file from oldname to the file newname. Note this does not copy, can overwrite files and removes the original file!
Each of these commands has additional options, you can find out more about linux commands by reading the man pages found using the
man
program. Try out
man cp
to see all of the options.
The Problem
Write the code for a program that prompts the user for two integer numbers and prints each number from the smaller number to the larger number.
You should also write code to find and print the GCD of the two numbers.
In this lab we will:
- write test cases
- write a README
- practice using conditions
Remember, you will be graded on style, syntax, functionality, test cases, and correctness.
An Example README.txt:
Lab3: Three Numbers
Author: Julian Dymacek
Date: 2017 Sept. 5
A program to compute statistics about three decimal numbers.
To compile:
make
To run:
./lab4
Test case:
input:
3 5
output:
3 4 5
GCD is 1
Implementation
You should start by creating test cases. What are possible tricky conditions that you should test? Next think about what data you will need to store. What kind of information do you need to output?
Handin
When you are done you may hand in your lab by using make handin
.
The lab is due at 11:59pm Sept. 19th 2017.