CS 70

First Day with CS 70

Let's play with a bit of C++.

Form a small group, two people ideally (but a three is okay if need be). You should all share a single computer and work together on it. Ideally, use the lab machine rather than your own laptop.

Fork it before you change anything. That link opens our copy, which you can read and run but not edit. Use OnlineGDB's Fork button to take your own copy; everything below assumes you are working in your fork rather than ours.

First Tasks

  • Load the code in the online compiler, and fork it so it's yours.
  • Run the code (it expects you to enter two numbers, one after the other).
  • What looks familiar?
  • What looks strange?
  • Can you remove the std:: prefixes?

Your First Change

There is a spelling mistake in one of the comments. Find it and fix it.

It is a comment, so nothing you do to it can break the program—which is exactly why it's a good first edit. It is also how you find out whether the fork worked: if you can save that change, you are working in your own copy. If you can't, you're still looking at ours, and you need to fork it before going any further.

An Experiment

Try changing hdist and vdist to be integers (int) instead of doubles. What happens when you run the program? Try entering 20 and 10 for the distances. What happens? Why do you think that is?

An “Askable” Page

This page integrates functionality you may have previously seen on sites like Piazza. At the bottom, you can ask questions about the content, and answer each other's questions. You can give it a try.

(When logged in, completion status appears here.)