Objective #12
12. Solving simple programs through selecting structures, operators, repetitive structures and functions in pseudocode.
Selecting structures:
If:
- The
if
statement evaluates a condition and executes a block of code if the condition is true.
If / else:
- The
if / else
statement allows the program to execute different blocks of code based on whether a condition is true or false.
While:
- The
while
loop repeats a block of code as long as a specified condition is true.
Repetitive Structures:
For:
- The
for
loop iterates a specific number of times, typically over a range of values. - Do / while:
- The
do / while
loop executes a block of code at least once, and then repeatedly executes the block as long as a specified condition is true.
Functions:
Definition:
- A function is a named block of code that performs a specific task or returns a value.
- Functions help in modularizing code, making it easier to understand, maintain, and reuse.
Calling:
- To use a function, you call it by its name and provide any required arguments.
Per Value:
- Function parameters passed by value create a copy of the original value, ensuring that changes made within the function do not affect the original variable.
Per Reference:
- Function parameters passed by reference allow the function to directly access and modify the original variable passed to it.
Comentarios
Publicar un comentario