Lesson 8 Flashcards

1
Q

FORTRAN I control statements are based on

A

IBM 704 hardware

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

RESULT OF THE CONTROL STATEMENTS IN THE FORTRAN I EVOLUTION:

A

All algorithms represented by the flowcharts can be coded with only two way selection statements and pretest loops.

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

CONTROL STRUCTURE

A

It is a statement and the statments that it controls.

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

What is the issue with the design of the control structure?

A

Can a control structure have multiple entries?

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

Two general categories of the selection statements

A

Two way selection

Multiple selection

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

What are the design issue with the two way selection statements?

A

What is the form and type of the control expression?

How are the then and the else clause specified?

How should the meaning of the nested selectors be specified?

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

When is the control expression placed in the parenthesis?

A

When the then reserved word or any other syntactic marker is not used.

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

Languages that have the control expression as arithmetic

A

C89, C99, C++, Python

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

Perl has clauses delimited by braces. T/F

A

T

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

The clause form in the ruby and the python is

A

Statement Sequences

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

Semantic rule for the Java nested if

A

the else clause resonant or matches with the nearest if.

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

AN laternative format to the semantic rule for the Java nested if is used, in which the compund statements are used. Which languages accept this solution?

A

Java, C, C sharp, C++

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

Which programming language does not allow else-less if statements?

A

ML

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

In ML, F sharp, Lisp, the selector is an expression. What is the rule for the type of value returned by then and else clause?

A

They should be of the same type.

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

What are the design issues with the multiple selection statements?

A

form and type of the control expression

selectable segments specified

is the execution flow through the structure restricted to include just a single slectable segment

cases values specified

What is done about the unrepresented expression values

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

The programming languages that allow the multiple selection statement:

A

C, C++, Java, and JavaScript

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

What are the design choices for C’s switch statement?

A

Control and constant expressions are of discreet type (int, char, enum); selectable segments can be statement sequences, bloacks or compound statements; Any number of segments can be executed in the execution of the construct; Default is for the unrepresented values; No restriction on the case expr.

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

What are the design choices for the C sharp’ s multiple selection statements?

A

Has static semantics ( disallows the implicit execution of more than one segment)
each selecatble segment ends with break or goto
the control expr and the case constants can be strings

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

Ruby’s multiple selections statement form:

A

case
when boolean expr then expr
……
when boolean expr then expr
[else expr]
end

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

Implementing the multiple selectors

A

Multiple conditional branching
Store case values in the table and use linear search
A hash table is for more than ten cases
array indices and array values are used for the case values and the case labels if the number of cases is small

21
Q

Scheme’s multiple selector form:

A

(COND
(predicate expr)
….
[(ELSE expr)]
)

Here, the predicate expr is a param

22
Q

Semantics of the multiple selectors of the Scheme:

A

The evaluated value of COND is the value of the expr associated with the first predicate expr that is true.

23
Q

What are the design issues with the iteration?

A

How is the iteration controlled?
Where is the control mechanism in the loop?

24
Q

Counter-controlled loop

A

A counting iterative statement
has a loop variable
means of specifying the initial, terminal, and the stepsize values

25
Q

Design issues with the Counter-controlled loop:

A

type and scope of the local variable
legal for the loop variable or loop param to be changed
loop params should be evaluated only once
value for the loop variable after the loop termination.

26
Q

C’s design choice for the counter-controlled loops:

A

If the second expr is absent in the for loop in C, the infinite loop is formed.
no explicit loop variable
first expr is evaluated only once and rest of the two are evaluated with each iteration
legal to branch into the body of a for loop in C

27
Q

C++’s counter controlled loop:

A

control expression can be boolean
initial expr can include the variable definitions

28
Q

Two programming languages that require the control expression to be boolean.

A

Java and C sharp

29
Q

Python’s counter-controlled loop:

A

The object is a call to the range or the list of the values
The else clause is optional and executes if the loop terminates normally.

30
Q

F sharp counter controlled loops:

A

No counter variables as it is pure functional language, therefore, simulated with the recursive functions.

31
Q

Logically-Controlled loops

A

based on the boolean expr

Desgin issues:
postest or pretest?
special case of the counting loop or a separate statement?

32
Q

C abd C++ have both posttest and the pretest forms, legal to branch into the loop body, not in Java as it has no goto. (True/False)

A

True

33
Q

Design issue for the nested loop?

A

should conditional be part of the exit
should control be transferrable out of more than one loop

34
Q

C, c++, Python, Riby and C sharp has the unconditional unlabeled exits. (T/F)

A

T

35
Q

Which lang have the unconditional labeled exits and labeled versions of continue?

A

Java and Perl

36
Q

C’ s for loop can be used to develop the user-defined iterator. (T/F)

A

T

37
Q

Java 5.0 for each is an interation based on the data structures. (T/F)

A

T

38
Q

Ruby blocks

A

sequences of the code delimited either by the braces or do and end.

39
Q

predefine diterator methods in the Ruby

A

times, each, upto

40
Q

Python’s yield statement:

A

Any method containing the yield statment is the generator because data is generated one element at the time.

history sensitive- same start at the initial as at the termination

41
Q

Unconditional branching

A

transfers control to the specific place in the program
main concern: readability

42
Q

Languages thta does not support the goto statement:

A

Java, Python, Ruby

43
Q

Which language does not use braces tof orm the compound statement?

A

Python

44
Q

WHich of the followinf languages does not use static semantic to specify the if construct to which the else clause belongs when the clause follows a nested if?

A

Ada

45
Q

WHich of the following languages has switch statement that has different static semantic than others?

A

C sharp

46
Q

WHich of the following languages does not have a counter controlled loop statement tht uses the for special word?

A

F sharp

47
Q

Which of the following languages have a predefined loop statement that is controlled by the data structure?

A

Perl, C++, C sharp, Java

48
Q

WHich of the following language has a goto statement?

A

C sharp, C, Ada