Introduction to Programming
Introduction to Programming
Programming
Programming is the process of writing instructions for a computer to
execute. It's used to solve problems efficiently using logic and structured
steps. Programming languages, like Python, C++, and Java, allow us to
communicate with computers.
by
MystarUni
Output Statements
25 Example
4
print"Hello," # Hello
print "Age" # Àge
Variable Declaration
What is a Variable? Declaration Syntax Variable Naming Data Types
A variable is a storage
Rules Integer: Whole numbers
DECLARE
location in memory that Variable names must start (positive, negative, zero)
variableName AS
holds data. Variables must with a letter or underscore,
DataType Float/Double: Decimal
be declared before use. contain only letters,
numbers, and underscores, numbers with fractional
INPUT variableName
Decision Structures
Simple IF Statement IF-ELSE Statement
1 2
IF condition THEN IF condition THEN
statement ENDIF statement1 ELSE
statement2 ENDIF
IF-ELSE IF Statement
3
IF condition1 THEN statement1 ELSE IF
condition2 THEN statement2 ELSE statement3 ENDIF
Control Structures (Loops)
Loops allow repeating a set of statements multiple times. They are essential
for automating repetitive tasks and processing large amounts of data.
FOR Loop
1
FOR counter FROM start TO end STEP increment
statement ENDFOR
WHILE Loop
2
WHILE condition statement ENDWHILE
DO-WHILE Loop
The DO-WHILE loop ensures that the statement inside the loop is executed
at least once, even if the condition is initially false. This is useful for
scenarios where you need to perform an action before checking a condition.
SET sum = 0
SET factorial = 1
ENDFOR