CT: Comprehensive Prerequisites Guide
IMPORTANT
Goal: CT doesnât need advanced math. It needs Logic and Attention to Detail.
1. Logic Basics
1.1 True vs False
- True: Yes, Correct, On.
- False: No, Incorrect, Off.
- Comparison:
- is True.
- is False.
1.2 Logical Operators
- AND: Both must be True.
- âI will go IF it is sunny AND I have money.â
- OR: At least one must be True.
- âI will eat IF it is Pizza OR Burger.â
- NOT: Opposite.
- âNOT Trueâ is False.
2. Arithmetic Basics
2.1 Operations
- Add/Sub/Mul: , , .
- Division:
/. (e.g., ). - Modulus (): The Remainder.
- (Because ).
- Use Case: Checking Even/Odd ().
2.2 Precedence (BODMAS)
- Brackets.
- Orders (Powers).
- Division / Multiplication (Left to Right).
- Addition / Subtraction (Left to Right).
3. The âStateâ Concept
- Variable State: A variable has one value at any specific moment.
- History: It doesnât remember what it was 5 minutes ago.
- Overwrite:
A = 5, thenA = 10. The 5 is gone forever.
4. Common Pitfalls
- Assignment vs Equality:
A = 10(Action: Make A 10).A == 10(Question: Is A 10?).
- Infinite Loops:
- Forgetting to update the variable in a
whileloop.
- Forgetting to update the variable in a
- Off-by-One:
- Lists start at Index 0.
- The last item is at Index
Length - 1.