CS115 Lab 1 Exercises:


If you have not already done so, please create a directory for this lab. You can follow these steps:

Programming Exercise 1

Programming Exercise 2

The prerequisites for CS115 include introductory programming experience. It is therefore expected that you are familiar with the concepts of one-dimensional arrays and looping constructs. If you require a review on arrays and the "for" loop, you can refer to the cs110 lab notes.

Use a text editor to write a C++ program that uses a one dimensional integer array to:

Compile your program. Your output should look something like this:

hercules[30]% avg
This program will compute the average of 5 numbers.
Enter number  1: 1
Enter number  2: 2
Enter number  3: 3
Enter number  4: 4
Enter number  5: 5
The sum of the numbers is: 15
The average of the numbers is: 3
The numbers are:

Unix/Linux Command Exercise

Note: This exercise assumes that you have created the directories from the "Preparation" section at the beginning of the lab exercises. If you have not done so, please create the directories and ensure that hello.cpp is in ~yourusername/cs115/lab1 directory (where yourusername is your own username)

Do the following in the order specified

  1. Start a script from your home directory
  2. Print your current working directory
  3. Change into the cs115/lab1 directory
  4. Use more to display the contents of hello.cpp
  5. Make a directory called Part1
  6. Copy hello.cpp into the Part1 directory
  7. List the contents of your current directory
  8. Without changing directories, list the contents of the Part1 directory
  9. Make a directory called BAK
  10. Move hello.cpp into BAK
  11. Change into the BAK directory
  12. Delete hello.cpp
  13. Move up one directory (Hint: you can use cd ..)
  14. Delete the BAK directory
  15. Exit the script
  16. Show the script to your lab instructor
  17. That's it! Have a good week!

This page last modified:
Thursday, 08-Jan-2009 10:21:09 CST

CS Dept Home Page
CS Dept Class Files
CS115 Lab Files

Copyright: Department of Computer Science, University of Regina.