|
IGNOU > IGNOU Assignments > MCA > MCA 2009 Assignments >Artificial Intelligence and Knowledge Management
IGNOU MCA Assignments
Question 3 Define a LISP function FACT-SUM-SQ that reads two integers and returns the factorial of the sum of their squares.
Ans.
(defun FACT-SUM-SQ()
(terpri)
(princ "Please enter the first number: ")
(setq n1 (read))
(setq n1 (* n1 n1))
(princ "Please enter the second number: ")
(setq n2 (read))
(setq n2 (* n2 n2))
(setq sum1 (+ n1 n2))
(do ((count sum1 (- count 1))
(product sum1 (* product (-count 1))
((equal 0 count) product))
Question 4 Write a LISP program that converts temperature in centigrades to equivalent temperature in Fahrenheit.
ANS.
(defun convert-centigrades()
(terpri)
(princ "Please enter the value for centrigades: ")
(setq centi (read))
(princ "The temperature in Fahrenheit is: ")
(princ (* (- centi 32) (/ 5 9)))
(terpri))
 
|