Skip to content
Book a Call → mycocoon.life
← Back to Blog Students 10 min read

CS50 Week 1 Explained: Your First Steps in C

Week 1 is where the blocks come off. Everything you did in Scratch (functions, conditionals, loops, variables) comes back in C, a language from the 1970s that still runs much of the world's infrastructure. C is strict and unforgiving about details, which is exactly why CS50 starts with it: you see what the computer is really doing.

🎓
An unofficial study guide. CS50 is Harvard University's Introduction to Computer Science, taught by David J. Malan. The lectures, notes and problem sets linked here belong to Harvard and are shared under CC BY-NC-SA 4.0. This guide is Cocoon's own writing and is not affiliated with or endorsed by Harvard. Take the course itself, free, at cs50.harvard.edu/x. Part of our CS50 study series. Keep track of your progress with our free CS50 Study Tracker.
CS50 Week 1 Explained: Your First Steps in C, pixel-art illustration
CS50 Week 1 Explained: Your First Steps in C
Thumbnail of CS50x 2026, Lecture 1: C
Watch the lecture

CS50x 2026, Lecture 1: C

2 h 30 min · Harvard University · CS50 on YouTube

Jump to the key moments

  1. 0:43Source code
  2. 14:33From Scratch to C
  3. 31:01Hello, you
  4. 44:03Terminal commands
  5. 55:49Conditionals
  6. 1:02:55Types
  7. 1:22:24Loops
  8. 1:44:46Functions
  9. 1:56:21Correctness, design, style
  10. 2:02:48Mario
  11. 2:18:32Integer overflow
  12. 2:26:47Floating-point imprecision

Source code, machine code, and the compiler

You write source code that people can read. The computer runs machine code, which is just bits. A compiler translates one into the other. In CS50's environment you type make hello to compile hello.c into a program called hello, then ./hello to run it. Change the code and you have to compile again. Forgetting to recompile is the most common Week 1 mistake.

The Scratch-to-C translation

The lecture maps each Scratch block to its C equivalent, and it's worth pausing on:

Types matter in C

In C you must declare what kind of value each variable holds: int for whole numbers, float and double for decimals, char for a single character, bool for true or false, long for bigger whole numbers, and CS50's string for text. Types come with limits, and the end of the lecture shows what happens when you hit them:

Correctness, design and style

CS50 grades on three things, and this lecture explains them. Correctness: does it work? Design: is it well written, without repetition or wasted effort? Style: is it readable, with consistent indentation and clear names? A program can be correct and still badly designed. If you've copied and pasted the same five lines three times, that's a sign you need a loop or a function.

Problem Set 1: what it asks

Where people get stuck

Check yourself

What's the difference between a while loop and a do-while loop?

A while loop checks its condition first, so it might never run. A do-while runs once, then checks. That makes it the natural choice for "ask until the answer is valid".

Why might 7 / 2 give you 3 in C?

Both numbers are integers, so C does integer division and throws away the remainder. If one of them is a float or double, you get 3.5.

You changed your code but the program still behaves the old way. What did you forget?

To recompile with make. The program you're running is the old compiled version.

Your program is correct but you pasted the same block of code three times. Which grading axis suffers?

Design. Repeated code belongs in a loop or a function.

Want to see how AI writes code compared with a human? Watch Build Lab put a website together live.

Try Build Lab →