Week 1: C
Trading Scratch's blocks for actual text: the same ideas, now typed by hand, and judged on more than just whether they run.
8 topics · 29 questions
Each topic is a path, not a menu: work down it in order and every question builds on the one above. Click any of them to watch the answer draw itself.
From Blocks to Text: Why C
- How it worksHow does a C program still boil down to the same inputs, decisions, loops, and outputs as a Scratch script?
- Common mistakeWhy isn't switching from Scratch to C just learning new vocabulary for the exact same ideas?
- Worked exampleWalk me through predicting what a simple C conditional will print, then checking that prediction.
- Going furtherWhat happens to a Scratch script's forever loop once the safety net of pre-built blocks disappears in C?
Your turn1 of 2
A Scratch script has 11 blocks chained together, one per step. Its C translation uses exactly one line per step, plus 5 extra lines of required boilerplate (headers, main, braces). How many total lines does the C file have?Anatomy of a C Program
- How it worksHow do the pieces of a minimal C program, from includes to main to braces, fit together?
- Worked exampleWalk me through a C program that prints hello, world and identify what each line does.
- Common mistakeWhy doesn't leaving off a semicolon just produce a warning instead of stopping compilation?
Your turn1 of 2
A minimal C program has 3 #include lines and 6 statements inside main. Counting only the #include lines and the statements inside main, how many lines is that?Data Types in C
- How it worksHow do int, char, float, double, and bool each reserve a different amount of memory for a different value?
- How it worksHow does a char actually store a small integer that just happens to be interpreted as a letter?
- Worked exampleFind the number of bytes an int and a double occupy in a typical C program, given int is 4 bytes and double is 8.
- Common mistakeWhy isn't a float exact enough to safely compare two decimal values with ==
Your turn1 of 2
A program declares 14 ints and 13 doubles. Given int is 4 bytes and double is 8 bytes, how many total bytes do these variables occupy?Operators and Expressions
- Worked exampleFind the result of the expression 7 / 2 and then the result of 7 % 2 in C.
- Common mistakeWhy doesn't a single equals sign inside an if condition compare two values?
- Going furtherWhat happens to the result of 7 / 2 the moment you rewrite it as 7.0 / 2?
Your turn1 of 2
In C, what does (7·4 + 2) / 4 evaluate to, using integer division?Conditionals in C
- How it worksHow do if, else if, and else chain together so exactly one branch ever runs?
- Worked exampleWalk me through a C conditional that prints whether a score of 85 is an A, B, C, or F.
- Common mistakeWhy isn't a switch statement just a faster version of an if-else chain?
- Going furtherWhat happens when a switch statement's case is missing a break?
Your turn1 of 2
An if-else chain has 6 'else if' branches after the initial if, plus one final plain else. How many total branches does the chain have, counting the initial if and the final else?Loops in C: while, do-while, for
- How it worksHow do while, do-while, and for each decide when to stop repeating?
- Worked exampleWalk me through a for loop that prints the numbers 1 through 5 on separate lines.
- Worked exampleWalk me through a do-while loop that keeps asking a user for a positive number until they give one.
- Common mistakeWhy isn't a do-while loop just a while loop with different keywords?
Your turn1 of 2
A for loop runs from i = 0 while i < 28, incrementing i by 1 each pass. How many times does its body run?Functions in C
- How it worksHow does each function get its own private set of local variables that no other function can see?
- Common mistakeWhy doesn't a function automatically know about a variable declared inside a different function?
- Going furtherWhat happens to a variable declared inside a function the moment that function returns?
- Ties togetherHow does calling a function in C foreshadow calling a custom block you built yourself in Scratch?
Your turn1 of 2
A function is called 15 times in a program, and each call declares 4 local variables. How many total local-variable declarations occur across all the calls, given each call gets its own fresh set?Correctness, Design, and Style
- How it worksHow do correctness, design, and style each judge a program along a completely different axis?
- Common mistakeWhy isn't a program that passes every test case automatically well designed?
- Going furtherWhat happens to a program's style score when every single variable is named x, y, and z?
Your turn1 of 2
A program's final grade is scored out of 218 points, split evenly between correctness, design, and style. How many points is each category worth?