LISP Questions & Answers – Syntax

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

Answer: a
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

Answer: b
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

Answer: c
Explanation: Any number of arguments can come in LISP single program. As an example, the addition (+) primitive takes any number of arguments.
advertisement
advertisement

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

Answer: a
Explanation: Correct syntax of the LISP is (<LISP Primitive> <arg1> <arg2> …).

5. Can LISP programs be nested?
a) Yes
b) No
View Answer

Answer: a
Explanation: Yes, the LISP programs can be nested.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What is the output of the following LISP statement?

(+ 3 4)

a) 3
b) 4
c) 7
d) Error
View Answer

Answer: c
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
advertisement

7. What is the output of the following LISP statement?

advertisement
(* 2 3 4)

a) 24
b) 234
c) 32
d) 4
View Answer

Answer: a
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

Answer: a
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

Answer: a
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

Answer: b
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.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.