LISP program to find the area of a circle using a function
kw.lisp
(write-line "———————————————————————————————————————————")
(write-line "Program to find the area of a circle")
(write-line "———————————————————————————————————————————")
(princ "Enter the radius ")
(setq r(read))
(defconstant PI 3.1416)
(defun Area()
(setq A(* PI r r))
(terpri)(princ "The area of a circle is ")
(write A)
(setq C(* 6.2831 r))
(terpri)(princ "The circumference of a circle is ")
(write C))
(Area)
(terpri)(format t "———————————————————————————————————————————")
Output
kodingwindow@kw:~$ clisp kw.lisp
———————————————————————————————————————————
Program to find the area of a circle
———————————————————————————————————————————
Enter the radius 10

The area of a circle is 314.15997
The circumference of a circle is 62.831
———————————————————————————————————————————
kodingwindow@kw:~$ 
Advertisement