CS 54 - Lab 1


Web Browsers

Internet Explorer tends to display C++ code embedded in my web pages strangely. I would highly recommend Firefox instead.


Program Template

// Name: <Your Name>
// Class and Section: CS 54, Section <n>
// Date: <Date>
// Purpose: <Statement of Purpose>

#include <iostream>
using namespace std;

int main()
{
  // Actual program goes here
  return 0;
}

Last week we typed this out without really understanding what this code was about. Naturally, we will cover certain parts in more detail as the semester progresses. For now, here's an overview of what this all means.

CodeMeaning
#include <iostream>Include functions that read & write to the UNIX (bash) prompt.
using namespace std;Include standard C++ language features.
int main()Begin the main() function. This function is automatically executed by the UNIX operating system. All C++ programs start here.
return 0;This signals the operating system your program is done. Your program will exit after this point.

Lab Assignment - Part I

Today we will be reviewing algorithms & style. Remember that an algorithm is a well defined sequence of steps that solves a problem. Algorithms can then be translated into actual code. Here's an example algorithm to make chocolate chip cookies:

Inputs: butter, shortening, sugar, brown sugar, eggs, vanilla, flour, baking soda, salt
Output: 50 cookies

  1. Mix butter, shortening, and sugars in a large bowl.
  2. Beat in eggs and vanilla.
  3. Combine flour, baking soda and salt; blend into creamed mixture. Stir in chocolate chips and nuts.
  4. Chill for a few minutes or let stand at cool room temperature for 30 minutes.
  5. Drop by rounded teaspoonfuls onto lightly greased baking sheets.
  6. Flatten slightly and smooth edges to make 1/2-inch thick cookie.
  7. Bake in a 375 °F oven for 8-9 minutes or until golden brown around the edges and still slightly under-baked in the center. Let stand on baking sheet for 5 minutes; remove to racks to let cool completely.

Source: Recipe Zaar.

Now try some algorithms on your own. Complete the first page of the Lab Worksheet.
NOTE: You may complete this worksheet using Microsoft Word or by hand. In either case, do it neatly. :)


Lab Assignment - Part II

Read & understand the CS 54 Style Guide. Answer the questions on page 2 of the Lab Worksheet.


Lab Assignment - Part III

We will be turning in our assignments using Blackboard. Today, I want you to turn in your lab worksheet on Blackboard (if you hand-wrote the worksheet, just submit a blank worksheet on Blackboard so you know how to do use Blackboard). Here's a quick tutorial on how to turn in your assignments on Blackboard.

  1. Open a web browser and go to http://blackboard.umr.edu/webapps/login/.
  2. Enter in your user ID and password (the same that you use to log in to all campus machines).
  3. Under My Courses click on the entry for CS 54.
  4. In the left pane, click on Assignments.
  5. Click on the Lab 01 assignment.
  6. Click Browse... and browse for your cs54_algorithms_style.doc file. It should be under s:\cs54\lab01.
  7. Click on Submit to submit the assignment.

Grading & Submission

I will be grading on the following criteria:


[Dilbert]