Your technical depth starts here.
Module 1 – Pseudocode Fundamentals · Variables and Data Types
Module 1 – Pseudocode Fundamentals
Pseudocode Fundamentals
- Pseudocode is an informal, language-independent way of writing an algorithm.
- Pseudocode describes logic without following the exact syntax of C++, Java, or Python.
- Pseudocode is used before implementation to design and verify an algorithm.
- Pseudocode should be:
- Clear.
- Unambiguous.
- Ordered.
- Finite.
- Easy to translate into code.
- BEGIN indicates the start of an algorithm.
- END indicates the end of an algorithm.
- INPUT or READ accepts data.
- OUTPUT or PRINT displays a result.
- Assignment stores a value in a variable.
x ← 10
10. The symbol ← generally means assignment.
11. In some pseudocode, = is also used for assignment.
12. Do not confuse assignment with equality testing.
13. x ← x + 1 increases the current value of x.
14. A variable is a named memory location.
15. A constant is a value that does not change during execution.
16. A variable should be initialized before it is used.
17. An uninitialized variable may produce an undefined or unexpected result.
18. A sequence executes statements from top to bottom.
19. Selection chooses among alternatives.
20. Iteration repeats a block of statements.
21. A condition evaluates to TRUE or FALSE.
22. A Boolean variable stores either TRUE or FALSE.
23. A comment explains logic and does not execute.
24. Pseudocode indentation indicates block structure.
25. Every opened block should have a corresponding ending statement.Variables and Data Types
- An integer stores whole numbers.
count ← 10
27. A real or floating-point value stores decimal numbers.price ← 10.5
28. A character stores one symbol.grade ← 'A'
29. A string stores a sequence of characters.name ← "Amit"
30. A Boolean stores TRUE or FALSE.
31. Type conversion changes a value from one type to another.
32. Integer division may discard the fractional part.
33. For example:7 DIV 2 = 3
34. Modulo returns the remainder.7 MOD 2 = 1
35. Division by zero is invalid.
36. Operator precedence determines evaluation order.
37. Parentheses have the highest priority.
38. Multiplication, division, and modulo generally occur before addition and subtraction.
39. Addition and subtraction are generally evaluated from left to right.
40. Use parentheses when output depends on precedence.Arithmetic Operators
- Addition:
a + b
42. Subtraction:a - b
43. Multiplication:a * b
44. Division:a / b
45. Integer remainder:a MOD b
46. Exponentiation may be represented by ^ or POWER.
47. Increment:x ← x + 1
48. Decrement:x ← x - 1
49. Compound assignment:x ← x + y
50. The expression on the right side is evaluated before assignment.
Arithmetic Dry Runa ← 10
b ← 3
x ← a + b * 2
y ← (a + b) * 2
z ← a MOD b
PRINT x, y, zEvaluation
x = 10 + (3 * 2) = 16
y = (10 + 3) * 2 = 26
z = 10 MOD 3 = 1Output
16 26 1