CS Micro 1 Unit
CS Micro 1 Unit
CS Micro 1 Unit
Properties of an Algorithm
Syntax Error
A syntax error occurs when the code violates the rules of the programming
language. These errors are detected by the compiler or interpreter during the
compilation or interpretation phase. Syntax errors prevent the code from
being successfully compiled or executed.
Logical Error
A logical error occurs when the program compiles and runs without issues, but
the output is not what was expected. This type of error is due to flaws in the
program's logic or algorithm, leading to incorrect results.
1. macOS
3. Void Type
1. Lexical Analysis: The compiler scans the source code and converts it
into tokens, which are the smallest units of meaning (like keywords,
operators, identifiers).
for Loop
The for loop is used when you know in advance how many times you want to
execute a block of code.
while Loop
The while loop is used when you want to execute a block of code repeatedly as long
as a condition is true. The condition is evaluated before executing the loop body.
do-while Loop
The do-while loop is similar to the while loop, but the condition is evaluated after
executing the loop body. This ensures that the loop body is executed at least once.
} i++; i++;
} return 0; return 0;
} }