Pre-Flight: Playground & Question System

* Not all activities on this page are graded. If the activity is not graded, it will be specified as such. It is to your advantage to complete all activities.


Howdy and welcome to CS 128! In this lesson, we introduce our online "playground" and question system used in our graded activities. Please follow along with this lesson to get the most out of our interactive textbook. We promise you that this will save you from a whole lot of frustration throughout the semester.

Activity Interface

This semester we are deploying our "playground" infrastructure for the in-browser compilation, execution, and grading of code written in the C++ programming language.

The activity interface is something you'll see very often: it will usually be attached to the lesson pages so that you can see and apply what you've just learned in action. Carefully read the instructions, complete this activity, and get a feel for our interface. The following activity is the only activity on this page with tabs, so play around with that too. Try rearranging them for no reason.

Activity: Hello To You Too

Ungraded Playground

Activity Prompt:

There are something called functions in C++. You are probably familiar with what it is. You'll learn more about it in the coming week, but for now, all you need to know to get started on this is:

  • In utilities.h, we told the compiler that we are going to have a function called HelloName that takes one argument, a string, and also returns a string. This is called declaration. Now compiler expects to be fed the directives of what this function should do.
  • In utilities.cpp, we have now fed the compiler the directives of what this function does. You don't need to worry about what's in there for now. This is called definition.
  • driver.cpp is the file we are interested in right now. This contains a main function. This function is very important because this is called at the startup of the program and is necessary for a program to run1.

If you didn't understand what these mean, that's okay. All you have to do is to edit the argument that's being passed onto HelloName in driver.cpp, and observe what happens! Play around until you are familiar with our interface.

  1. "A program shall contain a global function named main, which is the designated start of the program." is the exact quote from the C++ language standards.

#ifndef UTILITIES_H #define UTILITIES_H #include <string> std::string HelloName(std::string name); #endif // UTILITIES_H
#include "utilities.h" std::string HelloName(std::string name) { return "Hello, " + name +"!"; }
// Edit this file! #include "utilities.h" #include <iostream> int main() { std::cout << HelloName(/* This function takes string as an argument */) << std::endl; return 0; }

Graded activities

Almost all the programming exercises you encounter will contribute to your final grade: those with the yellow "Graded" tag contribute as such. Notice the last activity was an exception; the subsequent will be the norm. You will have an unmetered number of attempts on the programming exercises. Despite the following activity being graded, feel free to tinker with it. Your highest score will be recorded in the grade book, so do not fear getting the problem wrong initially.

Activity: Cowboy's Hello

Graded Autograder

Activity Prompt:

You are a cowboy 🤠 .   Using the std::cout syntax1 you saw in the last activity, print out "Howdy, world!" to console. This activity is autograded.

  1. The syntax is std::cout << "Your Text Here" << std::endl;

#include <iostream> int main() { // What should come here? return 0; }

Question System

One of the newer contributions to the course is the graded question system within our daily lessons. Depending on the lesson, there will be different questions: select one, fill in the blank, or string input. We hope these questions help fill in those gaps in knowledge that may be less intuitive.

Now it's time for you to tinker around with the question system. Feel free to look further at the history of your answers and the feedback provided.