Programming Flashcards

1
Q

Validation syntax using repeat loop

A

Output prompt
REPEAT
Input var
IF condition
THEN
Output prompt to re-enter
END IF
UNTIL condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Simple validation syntax using repeat loop

A

REPEAT
OUTPUT “ prompt”
INPUT var
UNTIL condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Validation using While loop

A

Outuput prompt
Input var
WHILE condition DO
Output prompt to re enter
Input var
ENDWHILE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Local variable

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Global variable

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

difference between multiple
if else and nested if

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly