programming concepts (paper 2) Flashcards
what happens to data used in a program
it is stored in memory locations while the program is running
what is a variable
a data item held in memory which may change value during program execution
what is a variable referred to by
its identifier
what are the different types of data variable can be
- integer (5, -297)
- real (3.12, 9.999)
- char (A, @, $, 4)
- string (Yes, Hello world)
- boolean (TRUE, FALSE)
what is a constant
a value that cannot change during the execution of hte program (CONSTANT VAT <- 0.2)
what is the diifference between a variable and a constant
a variable can change during the program execution, a constant does not
what is an input
when the user inputs data or a request into the program to get an output (INPUT Name)
what is an output
it is used to output data on the screen after information has been processed by the user (OUTPUT “Area = “, Length * Width)
what is a boolean expression
something which uss one or more logical operators and evalutes to either TRUE or FALSE
what is a sequence control structure
when two or more statements are written and executed one after the other in sequence
what is a selectrion control structure
comprises an IF or CASE statement and a logical expression (CASE OF… OTHERWISE… ENDCASE…, IF… THEN…)
give an example of a nested if statement
IF Num1 >= Num2 AND Num1 >= Num3
THEN
OUTPUT Num1
ELSE
IF Num2 >= Num1 AND Num2 >= Num3
THEN
OUTPUT Num2
ELSE
OUTPUT Num3
ENDIF
ENDIF
what does a case statement actually allow to happen
one of several brances of code to be executed depending on what data has been inputed by the user
give me an example of a case statement
INPUT MemberType
CASE OF MemberType
“Junior” : EntryFee <- 2.0
“Senior” : EntryFee <- 3.0
“Special” : EntryFee <- 0.0
OTHERWISE OUTPUT “Invalid member type”
ENDCASE
what does iteration mean
repetition
what loop is count-controlled
FOR… NEXT
give an example of a FOR.. NEXT loop nested
FOR Table <- 2 TO 10
FOR N <- 1 TO 10
Answer <- Table * N
OUTPUT Answer
NEXT N
NEXT Table