|
| 1 | +# 01 Foundations Hints |
| 2 | + |
| 3 | +Use these hints only after attempting each exercise. |
| 4 | + |
| 5 | +## types-and-io |
| 6 | + |
| 7 | +### Exercise 01 hints |
| 8 | + |
| 9 | +- Track `sum` while reading values. |
| 10 | +- Initialize `min` and `max` from the first input value, not from `0`. |
| 11 | +- Compute `average` as `sum / n` after the loop. |
| 12 | + |
| 13 | +### Exercise 02 hints |
| 14 | + |
| 15 | +- Read three tokens: `product`, `price`, `quantity`. |
| 16 | +- Multiply `price * quantity` for total. |
| 17 | + |
| 18 | +## operators-and-expressions |
| 19 | + |
| 20 | +### Exercise 01 hints |
| 21 | + |
| 22 | +- `hours = totalSeconds / 3600` |
| 23 | +- `minutes = (totalSeconds % 3600) / 60` |
| 24 | +- `seconds = totalSeconds % 60` |
| 25 | + |
| 26 | +### Exercise 02 hints |
| 27 | + |
| 28 | +- Apply discount before tax. |
| 29 | +- Tax percentage `x` is `x / 100.0`. |
| 30 | + |
| 31 | +## control-flow |
| 32 | + |
| 33 | +### Exercise 01 hints |
| 34 | + |
| 35 | +- Check multiples of 15 before checking 3 or 5. |
| 36 | + |
| 37 | +### Exercise 02 hints |
| 38 | + |
| 39 | +- Stop when you read `-1`. |
| 40 | +- Only divide by `count` if `count > 0`. |
| 41 | + |
| 42 | +## functions |
| 43 | + |
| 44 | +### Exercise 01 hints |
| 45 | + |
| 46 | +- Compare values step by step and keep a `currentMax`. |
| 47 | + |
| 48 | +### Exercise 02 hints |
| 49 | + |
| 50 | +- Convert characters with `std::tolower`. |
| 51 | +- Count `a, e, i, o, u`. |
| 52 | + |
| 53 | +## arrays-and-vectors |
| 54 | + |
| 55 | +### Exercise 01 hints |
| 56 | + |
| 57 | +- Store values in `std::vector<int>`. |
| 58 | +- Print from index `n - 1` down to `0`. |
| 59 | + |
| 60 | +### Exercise 02 hints |
| 61 | + |
| 62 | +- Loop through vector and increment `frequency` on match. |
| 63 | + |
| 64 | +## strings |
| 65 | + |
| 66 | +### Exercise 01 hints |
| 67 | + |
| 68 | +- Count transitions from whitespace to non-whitespace as new words. |
| 69 | + |
| 70 | +### Exercise 02 hints |
| 71 | + |
| 72 | +- Use two indexes (`left`/`right`) and skip non-letter characters. |
| 73 | +- Compare lowercase versions of letters. |
| 74 | + |
| 75 | +## scope-and-lifetime-basics |
| 76 | + |
| 77 | +### Exercise 01 hints |
| 78 | + |
| 79 | +- Use a single `grade` variable and assign it in one branch chain. |
| 80 | + |
| 81 | +### Exercise 02 hints |
| 82 | + |
| 83 | +- Keep loop variable scoped inside `for`. |
| 84 | +- Keep `sum` outside loop. |
| 85 | + |
| 86 | +## formatted-output-and-iomanip |
| 87 | + |
| 88 | +### Exercise 01 hints |
| 89 | + |
| 90 | +- Use `std::setw` for each column. |
| 91 | +- Keep `std::fixed << std::setprecision(2)` for money. |
| 92 | + |
| 93 | +### Exercise 02 hints |
| 94 | + |
| 95 | +- Set precision once before printing final results. |
| 96 | +- Reuse min/max pattern from foundations statistics exercises. |
0 commit comments