What is the output of the following LISP program? (NOTE: * means new line) [code](defun b(p) (+ p p) ) * (setq z 1) * (b z)[/code]

Linh Chi

New member
What is the output of the following LISP program? (NOTE: * means new line)
Code:
(defun b(p) (+ p p) )
* (setq z 1)
* (b z)
A. 2
B. 1
C. 3
D. error
 
Answer: a
Explanation: The parameter z=1 is passed to the function named b and then within the function the p+p=2 is done. Thus, function will return 2 as an output of this program.
Output: 2
 

Tìm kiếm

Back
Top