PSEUDOCODE Summary
PSEUDOCODE Summary
1. **Input/Output**
- **INPUT**: Read data from the user
```pseudocode
INPUT variableName
```
```pseudocode
OUTPUT variableName
```
2. **Variables**
- Declaring and assigning a variable
```pseudocode
variableName ← value
```
```pseudocode
IF condition THEN
statement
ELSE
statement
ENDIF
```
```pseudocode
IF condition THEN
statement
ENDIF
```
4. **Loops**
- **FOR Loop**: Used for a fixed number of iterations
```pseudocode
FOR i ← 1 TO n
statement
NEXT i
```
```pseudocode
WHILE condition DO
statement
ENDWHILE
```
- **REPEAT UNTIL Loop**: Executes at least once and repeats until a condition is met
```pseudocode
REPEAT
statement
UNTIL condition
```
```pseudocode
```pseudocode
```pseudocode
DECLARE arrayName[10]
arrayName[index] ← value
```
```pseudocode
FOR i ← 0 TO arraySize - 1
OUTPUT arrayName[i]
NEXT i
```
7. **Declaring a 2D Array**
```pseudocode
```pseudocode
DECLARE matrix[3, 3]
```
# This array will hold 7 rows and 24 columns, each element of type FLOAT
To access an element, you reference both the row and column index:
```pseudocode
```pseudocode
matrix[1, 2] ← 5
```
```pseudocode
value ← matrix[1, 2]
```
You can use nested loops to iterate over the elements in a 2D array.
```pseudocode
FOR i ← 0 TO 2
FOR j ← 0 TO 2
OUTPUT matrix[i, j]
NEXT j
NEXT i
```
10. **Standard Algorithms**
- **Linear Search**: Searching an array for a value
```pseudocode
FOR i ← 0 TO arraySize - 1
IF arrayName[i] = searchValue THEN
OUTPUT "Found at index ", i
EXIT
ENDIF
NEXT i
```
```pseudocode
low ← 0
high ← arraySize - 1
WHILE low ≤ high DO
mid ← (low + high) DIV 2
IF arrayName[mid] = searchValue THEN
OUTPUT "Found at index ", mid
EXIT
ELSEIF arrayName[mid] < searchValue THEN
low ← mid + 1
ELSE
high ← mid - 1
ENDIF
ENDWHILE
```
```pseudocode
FOR i ← 0 TO arraySize - 2
FOR j ← 0 TO arraySize - 2 - i
IF arrayName[j] > arrayName[j + 1] THEN
temp ← arrayName[j]
arrayName[j] ← arrayName[j + 1]
arrayName[j + 1] ← temp
ENDIF
NEXT j
NEXT i
```
11. **String Handling**
- Common string manipulation functions:
```pseudocode
```pseudocode
READ fileName
WRITE fileName, data
```
```pseudocode
CLOSE fileName
```