COL100 : Introduction to Computer Science : Labs (written, online and programming assignments)
All lab assignments are to be done in groups of at most two people. The two people in a group must belong to the same section.
Update Lab Work (ONLY FOR COL-100 STAFF)
View Lab Work
View Lab Roster
Lab Sessions:
Lab Assignment 1: Getting Familiar With Environment
Lab Assignment 2: Introduction to C++
Lab Assignment 3: I/O, if-then-else
Lab Assignment 4: Graded Assignment 1
Lab Assignment 5: Scope, Functions
Lab Assignment 6: Reference parameters, return values, square root by Newton's method
Lab Assignment 7: Graded Assignment 2
Lab Assignment 8: String functions
Lab Assignment 9: Graded Assignment 3
Lab Assignment 10: vector, istringstream, ostringstream
Lab Assignment 11: Graded Assignment 4
Lab Assignment 12: Stacks, Queues, GDB
Lab Assignment 13: Graded Assignment 5
Lab Assignment 14: Maps and Recursion
Lab References:
vector of vector
Use Stanford libraries without Qt (Easy to use)
simpio.h (STANFORD LIBRARY FUNCTIONS)
QT Creator (Beginners Guide)
Qt creator on Windows
vector(STL) Reference for Graded Assignment 3 submissions
FAQ
Resources required to attempt the labs
Here we list some instructions to set up the environment
required to attempt the lab assignments. This environment has already been
set up in LHC lab 503. These instructions are useful if you would like
to set up the environment locally on your laptop or desktop. You need Linux OS to set up the environment.
Note: If you only have access to a Windows/Mac machine, we recommend using VirtualBox to install Linux as a "virtual machine" inside your Windows/Mac operating system. You can follow this excellent tutorial on how to install VirtualBox, how to download a Linux ISO image, and how to install Linux (Ubuntu) as a virtual machine using VirtualBox: http://www.psychocats.net/ubuntu/virtualbox
Once you're booted to your Linux machine (or virtual machine), follow these instructions to ensure that all the required dependencies are installed:
- Install the necessary packages on your system: If you are running Ubuntu, Debian, Mint, or any other Debian derivative: Open a terminal and type:
$ sudo apt-get -y install openjdk-8-jre build-essential
If you are running another variant of Linux, ensure that the following
tools are installed on your system:
- Download and install the Qt Creator: Go to the Qt Creator official download site to download this software. Now scroll down to "Linux Host", and chose Qt 5.11.1 for Linux 64-bit (1.2 GB). (The exact version may change over time, but make sure to choose the Linux 64-bit option). Your download will begin. The file is very large, so it may take some time. It downloads a
.run
file to your machine. Execute this file to install Qt Creator on your system.
Important: For most screens, you must choose default options during installation. But at the screen labeled "Select Components", you must expand the "Qt 5.11.1" tree by clicking the >
triangle next to it, and then you must click the checkbox labeled, "(none)". This is absolutely crucial; if you forget to do this, your computer will not be able to compile and run C++ programs.
- Try to compile/run a sample project: Let's run a sample Qt Creator
project that uses the Stanford C++ libraries. We use these C++ libraries in our lab assignments. The Stanford C++ libraries also interact with Java, so if this project runs properly for you, then you will be sure that your Qt Creator and Java JDK are both set up properly. Here's what to do:
- Download the following project ZIP file to your computer: simple-project.zip.
- Un-zip the file's contents to a directory of your choice. After un-zip: you will find a directory named
simple-project
with several files and folders inside.
- Open the project: In Qt Creator, choose "File" --> "Open File or Project..." or press Ctrl+O. Navigate to the simple-project folder and open the file
simple-project.pro
.
- Qt Creator will ask you a few questions about how to set up the build process for this project. You can just accept the defaults and click "Configure Project".
- Build it: You should be able to Build (Ctrl+B) y our project in Qt Creator. If it builds properly, your C++ compiler and the Stanford C++ libraries are compiling properly. You can click the bottom "4 Compile Output" tab if you want to see the progress as it is compiling. (Recommended: In Qt Creator, click Tools → Options → Build & Run, and check the box labeled "Open Compile Output pane when building" to always see this output during compilation).
- Run it: Now that it's built, you should be able to Run (Ctrl+R) your
simple-project
. This is the part where Java is needed, so if your Java isn't properly installed, this is probably where it will fail. If it runs properly, you will see a window appear with a smiley face. Congratulations, you're done! Now your machine should work just fine for working on our lab assignments.