Skip to content

Repository files navigation

Assignment 2: Effective Programming in C and C++

Welcome to Assignment 2!

This repository is fully configured with a GitHub Codespace environment. You do not need to install anything on your computer to complete this assignment—all coding, compiling, and testing can be done directly in your web browser.

Step 0: Create a GitHub Account

If you don't already have a GitHub account, you must create one to use GitHub Codespaces:

  1. Go to https://github.com/signup and create a free account.
  2. Make sure you are logged in before proceeding to the next step.

Step 1: Launch Your Environment

  1. Go to www.codingrabbit.dev and sign in with the email address and password assigned to you.
  2. On the left tab, click Codespace Launch.
  3. Find your section and click Launch Codespace.
  4. At that point, you will be asked to sign into GitHub.
  5. A new browser tab will open with a web-based version of VS Code. Please wait a minute or two for the environment to build.

Step 2: Sign into Coding Rabbit

Our custom AI Teaching Assistant, CodingRabbit, is pre-installed in your environment to help you learn!

  1. Click Sign In. This will securely open a new browser tab and ask you to log into the course platform.
  2. After logging in successfully, the page will display your temporary authorization code. Click the Copy button on the screen.
  3. Switch back to your original VS Code browser tab and Paste the code into the prompt window at the top center of the screen to finish signing in.
  4. You can now use CodingRabbit for Homework Assist (to debug your current code) or Study Assist (to explain complex concepts)!

Step 3: Review Coding Examples from Lecture 4 & 5

Inside this repository, you will find two folders: lecture-04-examples and lecture-05-examples. Review the code in these examples to refresh your memory, and be sure to ask CodingRabbit if you have any questions about how they work!

Step 4: Start Your Assignment

Inside this repository, you will find 3 problem folders:

  • problem1/ - Linked List Manipulation
  • problem2/ - Minimum Spanning Tree
  • problem3/ - Rational Numbers

Each folder contains an Instructions.pdf and a starter .cpp or .c file.

  1. Use the Explorer icon (the file folders on the top left of your sidebar) to navigate into a problem directory.
  2. Click on the .c file (e.g., list.c) to open it in your editor and begin working!
  3. Compile and test your code using the terminal at the bottom of the screen.
  4. Click on the Coding Rabbit icon on the left of the screen anytime you need help.

Step 5: Shutting Down (Important!)

GitHub gives you a limited number of free compute hours per month for Codespaces. If you simply close your browser tab, the Codespace stays running in the background for 30 minutes before timing out, draining your free hours!

When you are done working for the day, always stop your Codespace:

  1. Open the VS Code Command Palette by pressing F1 (or click the gear icon in the bottom left -> Command Palette).
  2. Type Codespaces: Stop Current Codespace and hit Enter.
  3. You can safely close the tab once the session ends.

(Alternatively, you can manage and stop your active environments at github.com/codespaces)

Step 6: Saving & Submitting Your Work

Because you launched your Codespace from a template directly, your work is currently saved in an isolated, unpublished local repository inside the Codespace container.

How to Save Files

By default, VS Code will often auto-save your files. However, you can manually save any file by pressing Ctrl + S (Windows/Linux) or Cmd + S (Mac) on your keyboard, or by clicking File > Save in the top menu bar.

How to Submit (VS Code Method)

To safely back up your code to a private repository on your GitHub account and submit your assignment:

  1. Open the Source Control panel (the Git icon on the left sidebar in VS Code).
  2. Hover over the word Changes and click the + icon to stage all your changed files.
  3. Type a message in the text box (like "Finished assignment") and click the Commit button.
  4. Finally, click the large blue Publish Branch button.
  5. VS Code will prompt you to publish to a private repository on your GitHub account. Follow the prompts to confirm.

How to Submit (Terminal Method - Optional)

If you prefer using the command line, you can achieve the exact same result by running these commands in the terminal at the bottom of the screen:

  1. git add . (stages all your changed files)
  2. git commit -m "Finished assignment" (saves the changes to history)
  3. git push (VS Code will intercept this and ask if you want to publish the branch to a private repo)

Your code is now safely backed up and visible in your new private GitHub repository!

Step 7 (Optional, Advanced): Update Your Environment

This repository's .devcontainer setup (the tools and CodingRabbit extension pre-installed in your Codespace) is occasionally updated after courses have already started. If you're comfortable with git and want to pull in the latest version without disturbing your own work, run these commands in the terminal:

  1. git remote add upstream https://github.com/emowat/codingrabbit-mit14-assignment2.git (one-time setup — links you to the original course repository; skip this if you've already done it once)
  2. git fetch upstream
  3. git checkout upstream/main -- .devcontainer (pulls in only the environment configuration — your own code is untouched)

VS Code will detect that the environment configuration changed and prompt you to rebuild your container — click Rebuild when asked, and your environment will update in place. This shows up as a normal file change afterward, so it'll be included automatically the next time you save/submit your work (Step 6 above).

About

Assignment 2 from the MIT14 OpenCourseWare Material

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages