0% found this document useful (0 votes)
9 views4 pages

Algorithm and Programming Fundamentals

The document covers algorithm development and programming fundamentals, explaining algorithms as step-by-step procedures to solve problems, and includes examples such as summing numbers and finding the largest number. It discusses flowcharts, pseudocode, variables, data types, operators, strings, arrays, and control structures like if-else statements and loops. References are provided for further reading on Python and algorithms.

Uploaded by

hhackdog18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Algorithm and Programming Fundamentals

The document covers algorithm development and programming fundamentals, explaining algorithms as step-by-step procedures to solve problems, and includes examples such as summing numbers and finding the largest number. It discusses flowcharts, pseudocode, variables, data types, operators, strings, arrays, and control structures like if-else statements and loops. References are provided for further reading on Python and algorithms.

Uploaded by

hhackdog18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ALGORITHM DEVELOPMENT AND PROGRAMMING FUNDAMENTALS

1. ALGORITHM DEVELOPMENT

1.1 ALGORITHM
AN ALGORITHM IS A STEP-BY-STEP PROCEDURE USED TO SOLVE A PROBLEM
OR COMPLETE A TASK.

EXAMPLE 1 – SUM OF TWO NUMBERS:

1. START

2. INPUT NUMBER A

3. INPUT NUMBER B

4. SUM = A + B

5. OUTPUT SUM

6. END

OUTPUT: A = 5, B = 3 → OUTPUT: 8

EXAMPLE 2 – FIND LARGEST NUMBER:

1. START

2. INPUT A AND B

3. IF A > B THEN OUTPUT A

4. ELSE OUTPUT B

5. END

OUTPUT: A = 12, B = 9 → OUTPUT: 12

1.2 FLOWCHART
FLOWCHARTS REPRESENT ALGORITHMS VISUALLY USING SYMBOLS SUCH AS
OVALS (START/END), PARALLELOGRAMS (INPUT/OUTPUT), AND DIAMONDS
(DECISIONS).

EXAMPLE 1 – EVEN OR ODD:

- START

- INPUT NUMBER
- IF NUMBER MOD 2 = 0 THEN OUTPUT "EVEN"

- ELSE OUTPUT "ODD"

- END

OUTPUT: INPUT = 6 → OUTPUT: EVEN

EXAMPLE 2 – SIMPLE CALCULATOR:

- START

- INPUT TWO NUMBERS AND AN OPERATOR

- PERFORM OPERATION BASED ON OPERATOR

- OUTPUT RESULT

- END

OUTPUT: 8 * 2 → OUTPUT: 16

1.3 PSEUDOCODE
PSEUDOCODE IS A TEXTUAL DESCRIPTION OF AN ALGORITHM THAT LOOKS
LIKE PROGRAM CODE BUT USES PLAIN LANGUAGE.

EXAMPLE 1 – FACTORIAL OF A NUMBER:

START
INPUT N
SET FACT = 1
FOR I = 1 TO N
FACT = FACT * I
END FOR
OUTPUT FACT
END

OUTPUT: N = 4 → OUTPUT: 24

EXAMPLE 2 – CELSIUS TO FAHRENHEIT:

START
INPUT CELSIUS
FAHRENHEIT = (CELSIUS * 9 / 5) + 32
OUTPUT FAHRENHEIT
END

OUTPUT: CELSIUS = 0 → OUTPUT: 32


2. PROGRAMMING FUNDAMENTALS

2.1 VARIABLES AND DATA TYPES


VARIABLES HOLD DATA. DATA TYPES INCLUDE INTEGER, FLOAT, STRING, ETC.

EXAMPLE 1 – PYTHON CODE:

NAME = "ALICE"
AGE = 25
PRINT("NAME:", NAME)
PRINT("AGE:", AGE)

OUTPUT: NAME: ALICE AGE: 25

EXAMPLE 2 – DATA TYPES:

X = 10 # INTEGER
Y = 5.6 # FLOAT
Z = "HELLO" # STRING
PRINT(TYPE(X), TYPE(Y), TYPE(Z))

OUTPUT: <CLASS 'INT'> <CLASS 'FLOAT'> <CLASS 'STR'>

2.2 OPERATORS, STRINGS, AND ARRAYS


OPERATORS PERFORM MATH OR LOGIC. STRINGS HOLD TEXT. ARRAYS (LISTS)
HOLD MULTIPLE VALUES.

EXAMPLE 1 – ARITHMETIC OPERATORS:

A = 10
B = 3
PRINT(A + B, A - B, A * B, A / B)

OUTPUT: 13 7 30 3.3333333333333335

EXAMPLE 2 – STRINGS AND ARRAYS:

TEXT = "HELLO"
ARR = [1, 2, 3, 4]
PRINT(TEXT.UPPER())
PRINT(ARR[2])

OUTPUT: HELLO 3

2.3 IF-ELSE (CONDITIONS AND LOOPS)


CONDITIONALS DECIDE BETWEEN ALTERNATIVES. LOOPS REPEAT TASKS.

EXAMPLE 1 – IF-ELSE:

X = 18
IF X >= 18:
PRINT("ADULT")
ELSE:
PRINT("MINOR")

OUTPUT: ADULT

EXAMPLE 2 – FOR LOOP:

FOR I IN RANGE(1, 6):


PRINT(I)

OUTPUT: 1 2 3 4 5

REFERENCES (APA FORMAT)


GADDIS, T. (2021). *STARTING OUT WITH PYTHON* (5TH ED.). PEARSON.

CORMEN, T. H., LEISERSON, C. E., RIVEST, R. L., & STEIN, C. (2009).


*INTRODUCTION TO ALGORITHMS* (3RD ED.). MIT PRESS.

PYTHON SOFTWARE FOUNDATION. (2024). *THE PYTHON TUTORIAL*.


HTTPS://DOCS.PYTHON.ORG/3/TUTORIAL/

MALIK, D. S. (2018). *C++ PROGRAMMING: FROM PROBLEM ANALYSIS TO


PROGRAM DESIGN* (8TH ED.). CENGAGE LEARNING.

You might also like