This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Syntax”.
1. Which of the following is part of basic syntax in LISP programming?
Explanation: Primitives are part of basic syntax of LISP. + is not considered as a part of basic syntax of LISP. It is rather an example of the primitives.
2. Arguments are ____ a part of LISP Syntax.
d) not considered as
Explanation: Argument is a part of basic syntax of LISP. Even if there is no argument given then NIL is considered to be one of the arguments.
3. How many arguments do a single LISP program has?
c) Any number of arguments
Explanation: Any number of arguments can come in LISP single program. As an example, the addition (+) primitive takes any number of arguments.
4. What is the basic syntax of LISP? (Note: arg means argument here)
a) (<LISP Primitive> <arg1> <arg2> …)
b) (<LISP Primitive> <arg>)
c) (<arg> <LISP Primitive>)
d) (<arg1> <arg2> … <LISP Primitive>)
Explanation: Correct syntax of the LISP is (<LISP Primitive> <arg1> <arg2> …).
5. Can LISP programs be nested?
Explanation: Yes, the LISP programs can be nested.
6. What is the output of the following LISP statement?
(+ 3 4)
Explanation: Prefix notation is used in this statement. The “+” primitive is used for addition of numbers given to it in the form of arguments.
7. What is the output of the following LISP statement?
(* 2 3 4)
Explanation: More than two arguments are given to * primitive. It will multiply all the arguments supplied to it and prints the final result.
8. What is the output of the following LISP statement?
(+ 17 (* 22 1))
c) 17 (* 22 1)
Explanation: LISP programs are nested here. This statement will be completely evaluated. It will not give us the output in the form of (+ 17 (* 22 1)).
9. What is the output of the following LISP statement?
(/ 6 2)
Explanation: (/ 6 2) is evaluated as 6/2 and not 2/6 because (/ 6 2) is written in the prefix form.
10. Think of a way to write addition of four numbers using maximum possible braces?
a) (+ 1 2 3 4)
b) (+ (+ 1 2) (+ 3 4))
c) (+ 1 (+ 2 (+ 3 (4))))
d) (+ 1 2 (+ 3 4))
Explanation: In this 3 times braces () are used. Other possible way is (+ 1 (+ 2 (+ 3 4))) in which again 3 braces () are used.
Sanfoundry Global Education & Learning Series – LISP Programming Language.
To practice all areas of LISP, here is complete set of 250+ Multiple Choice Questions and Answers on LISP Programming Language.