Chrysolites Tech Academy

Video by freeCodeCamp.org · taught by David J. Malan · streamed from YouTube. All rights remain with the creator.

Lesson 2: Programming in C

About this lesson

The second lecture moves from dragging blocks to writing code as text, using the C programming language. It begins by translating the Scratch programs of the previous week into C, starting with the classic program that prints hello, world, and explains each part of it: the header file that is included, the main function where the program starts, the braces, the semicolons and the function that prints text. You then see how source code is turned into machine code by a compiler, and how to compile and run programs in the course's online programming environment using simple commands. The lecture introduces input from the user through a teaching library, storing values in variables, and printing them with format codes. It goes on to the core building blocks of the language: data types such as integers, decimal numbers, characters and strings; arithmetic and the remainder operator; conditions with if and else, combined with and or or; and the different kinds of loop, including while, for and do-while, illustrated with short programs. Along the way it shows how to define your own functions to avoid repeating code and to make programs easier to read, and it stresses the importance of good style. The final part reveals two limits of how computers store numbers: integer overflow, when a count grows too large for the bits available and wraps around, and floating-point imprecision, when decimal fractions cannot be stored exactly. Afterwards, read Chapter 2 of the course book, which illustrates overflow with a small counter.

Install Chrysolites Tech Academy

Android / Chrome / Edge: open the browser menu and choose Install app or Add to Home screen.

iPhone / iPad (Safari): tap the Share button, then Add to Home Screen.