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?
a) Primitive
b) +
c) NULL
d) #include
View Answer
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.
a) sometimes
b) always
c) vever
d) not considered as
View Answer
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?
a) One
b) Two
c) Any number of arguments
d) Three
View Answer
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>)
View Answer
Explanation: Correct syntax of the LISP is (<LISP Primitive> <arg1> <arg2> …).
5. Can LISP programs be nested?
a) Yes
b) No
View Answer
Explanation: Yes, the LISP programs can be nested.
6. What is the output of the following LISP statement?
(+ 3 4)
a) 3
b) 4
c) 7
d) Error
View Answer
Explanation: Prefix notation is used in this statement. The “+” primitive is used for addition of numbers given to it in the form of arguments.
Output: 7
7. What is the output of the following LISP statement?
(* 2 3 4)
a) 24
b) 234
c) 32
d) 4
View Answer
Explanation: More than two arguments are given to * primitive. It will multiply all the arguments supplied to it and prints the final result.
Output: 24
8. What is the output of the following LISP statement?
(+ 17 (* 22 1))
a) 39
b) 3
c) 17 (* 22 1)
d) Error
View Answer
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)).
Output: 39
9. What is the output of the following LISP statement?
(/ 6 2)
a) 3
b) 1/3
c) Division
d) Error
View Answer
Explanation: (/ 6 2) is evaluated as 6/2 and not 2/6 because (/ 6 2) is written in the prefix form.
Output: 3
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))
View Answer
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.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Computer Science Books
- Check LISP Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship