Programming Flashcards
Validation syntax using repeat loop
Output prompt
REPEAT
Input var
IF condition
THEN
Output prompt to re-enter
END IF
UNTIL condition
Simple validation syntax using repeat loop
REPEAT
OUTPUT “ prompt”
INPUT var
UNTIL condition
Validation using While loop
Outuput prompt
Input var
WHILE condition DO
Output prompt to re enter
Input var
ENDWHILE
Local variable
A variable declared inside a function is local variable
the lifetime of local variable exists only during the function
as the function ends, local variable ends as well
These are needed to be declared when writing a code of a function
Global variable
variable declared outside a function is global variable.
The lifetime of global variable is as the program is running.
it doesn’t need to be declared if you are questioned about writing a code on a function or a procedure and it is stated that this variable is global.
difference between multiple
if else and nested if
Multiple if-else statements are used when you have different, independent conditions.
Nested if statements are used when conditions depend on previous conditions.
What to use?
If the conditions are logically related and need to be checked one inside another, a nested if is more suitable. If they are independent and exclusive, multiple if-else is preferred.