Variables & Data Types
Your programs need to store data. I will show you how variables work, what types exist, and which one to pick for each situation.
Lessons
1. Intro
The Goal
2. What is a Variable?
Containers for values
3. Vocabulary - Data Types
What types exist
4. The int Type
Storing integers
5. int Range and Limits
What fits in int
6. Quiz: Integer Basics
Integer types
7. Overflow - What Happens
Going past limits
8. Quiz: int Type
Test your understanding
9. The long long Type
64-bit integers
10. When to Use long long
Avoiding overflow bugs
11. Quiz: Large integers
Large integers
12. The LL Suffix
Marking large constants
13. The double Type
Floating-point values
14. Floating Point Precision
Not infinite precision
15. Quiz: Integer type
Integer type
16. Precision Errors in Practice
When rounding matters
17. When to Use double
Decimals vs integers
18. Quiz: Decimal numbers
Decimal numbers
19. The char Type
Storing letters
20. ASCII Values
The character encoding
21. Character Arithmetic
Math with letters
22. Challenge: Simple Addition
Add two numbers
23. Quiz: char Type
Test your understanding
24. The bool Type
Binary states
25. Boolean in Conditions
Using bool with if
26. The string Type
Storing words
27. Basic String Operations
Working with text
28. Challenge: Rectangle Area
Calculate with doubles
29. Quiz: Text storage
Text storage
30. Declaring Variables
How to create them
31. Variable Naming Rules
Legal identifiers
32. Quiz: Data storage
Data storage
33. Variable Naming Conventions
Readable code
34. Initialization vs Declaration
Starting values
35. Quiz: Data storage
Data storage
36. Uninitialized Variables
Random data
37. Constants with const
Unchangeable variables
38. Why Use Constants
Safer code
39. Quiz: Data storage
Data storage
40. Type Conversion - Implicit
Silent changes
41. Type Conversion - Explicit
Forced changes
42. Quiz: Data storage
Data storage
43. Common Type Mistakes
Typical errors
44. Printing Variables
Displaying values
45. Printing Multiple Values
Combining text and data
46. Quiz: Integer type
Integer type
47. Problem - Calculate Rectangle Area
Practice with variables
48. Problem - Convert Celsius to Fahrenheit
Practice with doubles
49. Problem - Sum of Two
First real problem
50. Sum of Two - The Idea
Main approach
51. Sum of Two - Implementation
Working solution
52. Lessons from Sum of Two
What we learned
53. Problem - Temperature Convert
Celsius to Fahrenheit
54. Temperature Convert - The Idea
Formula application
55. Temperature Convert - Implementation
Working solution
56. Lessons from Temperature Convert
What we learned
57. Section Recap
What we learned