Unit 1: Foundations of Computing
Overview
This unit covers computer science, hardware/software, algorithms, first program, variables, primitive types. Follow the same problem progression as Python so that the main comparison is language syntax and semantics. Use the worked examples as starting points, then complete the activities independently.
Lesson 1.1: Computer science and problem solving
Reading References
- Official C++ language guide and standard-library documentation.
- Corresponding Python course lesson for the shared problem context and learning objective.
Learning Objectives
- Explain this concept using C++ terminology.
- Trace a short program and predict its behavior before execution.
- Modify and test the example independently.
Concept Explanation
Computer science and problem solving is taught through the shared course datasets and requirements. The Python curriculum supplies a common problem context, not syntax to translate mechanically. In C++, make the type system, object lifetime, standard-library contracts, ownership, and failure behavior explicit. This lesson focuses on: distinguish an algorithm from its C++ implementation; a clean build does not prove algorithmic correctness.
Worked Example
std::cout << "Computer science turns problems into precise, testable steps.\n";
Trace: predict the output before compiling. Identify declarations, values, control-flow decisions, and state changes in order. Then compile and compare actual output with the prediction. The lesson example is intended to be independently compilable.
Expected Behavior or Output
Output observed when the worked example was run with empty standard input (g++ 13.3, C++20; the text of the output does not depend on the operating system):
Computer science turns problems into precise, testable steps.
Common Mistakes
- A successful compile does not establish that the algorithm satisfies the requirement.
- Distinguish an algorithm from its C++ implementation.
- A clean build does not prove algorithmic correctness.
Activities
- Trace the computer science and problem solving example and predict its output before compiling.
- Adapt the example to Avery’s profile and greeting and preserve the same observable requirement using idiomatic C++20.
- Add one boundary case and one invalid or missing-data case; state the expected result and implement the handling.
- Write a short test or trace table, then explain the C++ type, lifetime, ownership, iterator, or error-handling rule that matters here.
Accessibility Practice
Navigate the complete source file by line, word, and character using the learner’s access technology. Read punctuation and indentation, run from the terminal, and inspect standard output and errors sequentially.
Skills Checklist
- I can explain the concept in C++ terminology.
- I can trace and predict the example.
- I can modify and run the code independently.
- I can identify and correct a common error.
- I can read source and output accessibly.
Lesson 1.2: Your first program
Reading References
- Official C++ language guide and standard-library documentation.
- Corresponding Python course lesson for the shared problem context and learning objective.
Learning Objectives
- Explain this concept using C++ terminology.
- Trace a short program and predict its behavior before execution.
- Modify and test the example independently.
Concept Explanation
Your first program is taught through the shared course datasets and requirements. The Python curriculum supplies a common problem context, not syntax to translate mechanically. In C++, make the type system, object lifetime, standard-library contracts, ownership, and failure behavior explicit. This lesson focuses on: provide main with the correct signature; include the declaration header and use std::cout.
Worked Example
const std::string greeting_name = "Avery"; std::cout << "Hello, " << greeting_name << "!\n";
Trace: predict the output before compiling. Identify declarations, values, control-flow decisions, and state changes in order. Then compile and compare actual output with the prediction. The lesson example is intended to be independently compilable.
Expected Behavior or Output
Output observed when the worked example was run with empty standard input (g++ 13.3, C++20; the text of the output does not depend on the operating system):
Hello, Avery!
Common Mistakes
- Forgetting to rebuild after editing can leave an older executable on disk.
- Provide main with the correct signature.
- Include the declaration header and use std::cout.
Activities
- Trace the your first program example and predict its output before compiling.
- Adapt the example to Avery’s profile and greeting and preserve the same observable requirement using idiomatic C++20.
- Add one boundary case and one invalid or missing-data case; state the expected result and implement the handling.
- Write a short test or trace table, then explain the C++ type, lifetime, ownership, iterator, or error-handling rule that matters here.
Accessibility Practice
Navigate the complete source file by line, word, and character using the learner’s access technology. Read punctuation and indentation, run from the terminal, and inspect standard output and errors sequentially.
Skills Checklist
- I can explain the concept in C++ terminology.
- I can trace and predict the example.
- I can modify and run the code independently.
- I can identify and correct a common error.
- I can read source and output accessibly.
Lesson 1.3: Variables and data types
Reading References
- Official C++ language guide and standard-library documentation.
- Corresponding Python course lesson for the shared problem context and learning objective.
Learning Objectives
- Explain this concept using C++ terminology.
- Trace a short program and predict its behavior before execution.
- Modify and test the example independently.
Concept Explanation
Variables and data types is taught through the shared course datasets and requirements. The Python curriculum supplies a common problem context, not syntax to translate mechanically. In C++, make the type system, object lifetime, standard-library contracts, ownership, and failure behavior explicit. This lesson focuses on: initialize every built-in variable; select types that preserve fractional values; distinguish assignment from equality.
Worked Example
const std::string name = "Avery"; const int age = 16; const double height_m = 1.72; const std::string favorite = "Computer Science"; std::cout << name << ", " << age << ", " << height_m << " m, " << favorite << '\n';
Trace: predict the output before compiling. Identify declarations, values, control-flow decisions, and state changes in order. Then compile and compare actual output with the prediction. The lesson example is intended to be independently compilable.
Expected Behavior or Output
Output observed when the worked example was run with empty standard input (g++ 13.3, C++20; the text of the output does not depend on the operating system):
Avery, 16, 1.72 m, Computer Science
Common Mistakes
- Initialize every built-in variable.
- Select types that preserve fractional values.
- Distinguish assignment from equality.
Activities
- Trace the variables and data types example and predict its output before compiling.
- Adapt the example to Avery’s profile and greeting and preserve the same observable requirement using idiomatic C++20.
- Add one boundary case and one invalid or missing-data case; state the expected result and implement the handling.
- Write a short test or trace table, then explain the C++ type, lifetime, ownership, iterator, or error-handling rule that matters here.
Accessibility Practice
Navigate the complete source file by line, word, and character using the learner’s access technology. Read punctuation and indentation, run from the terminal, and inspect standard output and errors sequentially.
Skills Checklist
- I can explain variables and data types using correct C++ terminology and distinguish it from the closest Python equivalent.
- I can trace the example and justify its output using C++ rules.
- I can implement the same requirement for Avery’s profile and greeting without copying Python syntax.
- I can test a normal case, a boundary case, and a relevant invalid or failure case.
- I can compile the program, interpret diagnostics, and navigate source and terminal output using my access technology.