Input & Output
Your programs need to get data from users and display results. I will show you how to read different types, handle errors, and format output.
Lessons
1. Intro
The Goal
2. Reading Input with cin
The extraction operator
3. How cin Works
Reading from the input buffer
4. Reading int Values
Integer input
5. Reading double Values
Floating-point input
6. Quiz: Reading Input
Input operations
7. Reading char Values
Character input
8. Quiz: Basic Input
Test your understanding
9. Reading Multiple Values
Chained extraction
10. Reading Multiple Values
Sequential reads
11. Input Order Matters
Reading in correct sequence
12. Quiz: Multiple Inputs
Test your understanding
13. Reading Strings with cin
String extraction
14. The Whitespace Problem
Spaces terminate extraction
15. Reading Full Lines with getline
Reading entire lines
16. Mixing cin and getline
Common mixing error
17. Challenge: Temperature Converter
Apply a formula
18. Quiz: Reading full lines
Reading full lines
19. Fixing the Newline Problem
Discarding leftover characters
20. Input Validation Basics
Why inputs fail
21. When Input Fails
Understanding failure state
22. Quiz: Knowledge check
Knowledge check
23. Checking Input State
Detecting read errors
24. Formatting Output
Controlling output appearance
25. Setting Precision
Controlling decimal digits
26. Quiz: Counter-based loop
Counter-based loop
27. Fixed vs Scientific
Notation styles
28. Setting Width
Field width control
29. Quiz: Conditional execution
Conditional execution
30. Common Input Patterns
Reading unknown quantity
31. Reading Until EOF
Processing all input
32. Reading Until Sentinel
User-controlled termination
33. Problem - Calculate Average
Practice reading and computing
34. Problem - Echo Input
Practice string input
35. Problem - Watermelon
First CF problem
36. Watermelon - The Idea
Main approach
37. Watermelon - Algorithm
How to solve
38. Quiz: Knowledge check
Knowledge check
39. Watermelon - Implementation
Complete solution
40. Lessons from Watermelon
What we learned
41. Problem - Way Too Long Words
Multiple test cases
42. Way Too Long Words - The Idea
Main approach
43. Reading Multiple Inputs
Handle n test cases
44. Quiz: Large integers
Large integers
45. Way Too Long Words - Algorithm
How to solve
46. Way Too Long Words - Implementation
Complete solution
47. Lessons from Way Too Long Words
What we learned
48. Section Recap
What we learned