# LISP Questions & Answers – Iteration

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Iteration”.

1. Which is a general strategy for controlling how a computation evolves?
a) Recursion
b) Mapping
c) Iteration
d) None of the mentioned

Explanation: Iteration is said to be one kind of control strategy and it is a general strategy for controlling how a computation evolves.

2. Which provides a way to write simple counting-oriented iteration procedures?
a) Do
b) Dotimes
c) Recursion
d) Iteration

Explanation: Dotimes provides a way to write simple counting-oriented iteration procedures.

3. What will happen if a dotimes form has no result form?
a) Nil
b) T
c) Both Nil & T
d) Nothing

Explanation: If a dotimes form has no result form, the dotimes will return nil and its purpose is to arrange for side effects.

4. What will be occupied in the first part of DO?
a) Procedures
b) List
c) Iterators
d) List of parameters

Explanation: The first part of a DO is always occupied by a list of parameters that are all bound to initial values.

5. Which are evaluated before initial binding?
a) All initialisation forms
b) Iterations
c) Procedures
d) None of the mentioned

Explanation: All initialization forms are evaluated before before inital binding.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What is the output of the given statement?

`span class="sy0"> * (prog1 (setf a 'x) (Setf b 'y) (setf c 'z))`

a) X
b) Y
c) Z
d) XYZ

Explanation: The statement contains prog1 which is used to print the first value of the given list.
Output:
X

7. What is the output of the given statement?

```span class="sy0"> * (defun dotimes-expt (2 4)
(let ((result 1));
(dotimes (count 4 result);
(setf result (* 2 result)))));```

a) 2
b) 4
c) 8
d) 16

Explanation: This statement will calculate the power in given terms.
Output:
16

8. What is the output of the given statement?

`span class="sy0"> * (setf freezing 32 boiling 212)`

a) 32
b) 212
c) Both 32 & 212
d) None of the mentioned

Explanation: This statement will return last value always.
Output:
212

9. What is the output of the given statement?

```span class="sy0"> * (setf cheers '(cheer cheer cheer))
* (setf loop-count 0)
* (loop (when (endp cheers) (return loop-count)) (setf cheers (rest cheers)) (setf loop-count (+ loop-count 1)))```

a) 0
b) 2
c) Cheers
d) 3

Explanation: This statement will count the number of times does the cheers appears by loop.
Output:
3

10. What is the output of the given statement?

`span class="sy0"> * (progn (setf a 'x) (setf b 'y) (Setf c 'z))`

a) X
b) Y
c) Z
d) XYZ

Explanation: This statement will make the use of progn to print last value in the given list.
Output:
Z

Sanfoundry Global Education & Learning Series – LISP Programming Language. 