Module 2: C

Tuesday, June 29th Class on Zoom

There will be a class starting at 5:30 PM on Tuesday, June 29th. The information to access the Zoom meeting will be shared on Slack. The class runs until 7:30 PM

Watch the Lecture Video

Use the controls in the video player to adjust the window size, playback speed, closed captions, and more.

  • Press the F key to make the video player fullscreen
  • Change the video quality by clicking on the gear icon (hover over the player to see it)
  • Change the playback speed by clicking on the gear icon
  • Transcript

Listen to Lecture Audio Only

Lecture Notes

Short Demo Videos

Data Types

Operators

Conditional Statements

Loops

Command Line

Setting a Variable to a String Value

Slides

C Source Code Examples

  • Index (listing of files that you can download one-by-one
  • PDF (all of the code printed out)
  • Zip (all of the C source code files)

Scratch to C Comparison Chart

Accessing the Integrated Development Environment (IDE)

To access the CS50 IDE, go to https://ide.cs50.io

You will need to use the GitHub username and password that you created in Module 0.

Helpful Utilities that You Will Need

You can find information about each of these CS50 IDE utilities in the Lecture Video.

  • help50
  • style50
  • test50
  • check50

Terminal Commands

Note: the -‘s are not part of the commands.

  • ls – to list files and folders
  • rm – remove a file
  • rmdir – remove a directory (a folder)
  • mv – move a file
  • mkdir – make a directory (a folder)
  • cd – change directory (a folder)
  • .. – one directory (a folder) above
  • . – the current directory (folder)
  • ~/ – your home directory (a folder)

Data Types in C

Here’s a partial list of the various data types in the C programming language:

  • bool
  • char
  • double
  • float
  • int
  • long
  • string

Functions in the CS50 Library

  • get_char()
  • get_double()
  • get_float()
  • get_int()
  • get_long()
  • get_string()
  • get_positive_int()

printf Formatting Codes

  • %c – character
  • %f – floating point
  • %i – integer
  • %li – long
  • %s – string

Mathematical Operators in C

  • + addition
  • subtraction
  • * multiplication
  • / division
  • % remainder
  • == checks for equality
  • > greater than
  • < less than
  • >= greater than or equal
  • <= less than or equal

Boolean Operators in C

  • || or
  • && and

COMPLETE: Lab 1

This lab does not count towards your grade but must be completed.

Due Date

Lab 1 is due on Monday, July 5th, 2021 at 9:00 PM.

Step 1 – Join the WR510 GitHub Course via GitHub

Have your GitHub username and password handy and then visit this link to join the WR510 GitHub course:

https://submit.cs50.io/invites/85037ee22333438184e4604f3d2cb5d4

Step 2 – Complete Part 1 of the Lab “Hello”

Complete this step-by-step lab that will take you through the CS50 IDE and the “hello world” program. At the end of Part 1, you will be asked to use the submit50 tool to send your work to the instructor.

Step 3 – Complete Part 2 of the Lab “Population Growth”

This lab will have you create code that determines how long it takes for a population to reach a particular size.

COMPLETE: Problem Set 2

Due Date

Problem Set 2 is due on Monday, July 5th, 2021 at 9:00 PM.

Problem 1 (select one)

Problem 2 (select one)