

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Memory Management
incomplete
2: C Program Structure
incomplete
3: Interpreted Quiz
incomplete
4: C Is Compiled
incomplete
5: Comments
incomplete
6: Basic Types
incomplete
7: Strings
incomplete
8: Printing Variables
incomplete
9: Compilation: Types
incomplete
10: Variables
incomplete
11: Constants
incomplete
12: Functions
incomplete
13: Void
incomplete
14: Unit Tests
incomplete
15: Math Operators
incomplete
16: If Statements
incomplete
17: Logical Operators
incomplete
18: Ternary
incomplete
19: Type Sizes
incomplete
20: Sizeof
incomplete
21: For Loop
incomplete
22: While Loop
incomplete
23: Do While Loop
incomplete
24: Pragma Once and Header Guards
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
You've already seen me do a printf() magic a few times. Unfortunately, in C it isn't as easy to do string interpolation (what f-strings do in Python).
Instead of:
print(f"Hello, {name}. You're {age} years old.")
We have to tell C how we want particular values to be printed using "format specifiers".
Common format specifiers are:
%d – digit (integer)%c – character%f – floating point number%s – string (char *)printf("Hello, %s. You're %d years old.\n", name, age);
The print() function in Python automatically adds a newline character (\n) at the end of the string. In C, we have to do this manually.
printf("Hello, world!\n");
In the space provided print:
Default max threads: A
Custom perms: B
Constant pi value: C
Sneklang title: D
Use format specifiers to replace A-D with the already provided variables.
Do not add precision to the floating point number.