6 Sep 2018

Compiling

Instructions

  • We will be using the online programming education tool repl.it

    • Open the following link in a new browser tab (Middle Click): repl.it C++ template

    • Click the fork button on the top of the page.

    • You now have a private copy of the template. Copy and save the new URL.

  • Please spend a few minutes discussing the instructions and/or your work with other students at your table.

  • Please submit your work via submission form (see below).

Chunk 1: A Story

  • Modify the following chunk so that it runs without error

    • Comment out any lines that cause errors

  • Add at least 2 comments explaining

  • Can you guess what the numbers represent (approximately)?

// Time for a Story
#include <iostream>
#include <string>
int main()
{
  // Let's start with some ``actors''
  //
  // our dog, a noble creature:
  int boulder = 5;
  // our house
  int home = 2;
  // A newborn
  float aspen = 7.0/365.0;
  // occasional visitors
  std::string ups_man = "A very nice guy";

  // Now, let's do something with them
  std::cout << "Boulder - Aspen: " ;
  std::cout << boulder - aspen;
  std::cout << std::endl;

  // Not friends:
  std::cout << "Boulder + Deliveries: ";
  std::cout << boulder + ups_man;

  // What's going on here?
  std::cout << "Boulder / Home: " ;
  std::cout << boulder / home;
  std::cout << std::endl;
}

Chunk 2: Your Turn

  • Using the above chunk as a template, tell a short story

    • Please include at least 2 actors (variables)

    • Make the actors do at least 2 things (+, -, …​, or other functions)

  • Provide comments explaining what’s happening.

int main()
{
  // First, define the actors

  // Next, make the actors do things

  // Add comments to help the reader follow
}