LISP program for the positive-negative test of a given number
kw.lisp
(write-line "———————————————————————————————————————————")
(write-line "Program to check a number is +ve or -ve")
(write-line "———————————————————————————————————————————")
(princ "Enter the number ")
(setq a(read))
(if(= a 0)
(format t "~%~d is neither +ve nor -ve "a))
(if(> a 0)
(format t "~%~d is +ve number "a))
(if(< a 0)
(format t "~%~d is -ve number "a))
(terpri)(format t "———————————————————————————————————————————")
Output
kodingwindow@kw:~$ clisp kw.lisp
———————————————————————————————————————————
Program to check a number is +ve or -ve
———————————————————————————————————————————
Enter the number -1

-1 is -ve number 
———————————————————————————————————————————

kodingwindow@kw:~$ clisp kw.lisp
———————————————————————————————————————————
Program to check a number is +ve or -ve
———————————————————————————————————————————
Enter the number 0

0 is neither +ve nor -ve 
———————————————————————————————————————————
kodingwindow@kw:~$ 
Advertisement