LISP program to swap the given numbers
kw.lisp
(write-line "———————————————————————————————————————————")
(write-line "Program to swap the given numbers")
(write-line "———————————————————————————————————————————")
(princ "Enter the 1st number a=")
(setq a(read))
(princ "Enter the 2nd number b=")
(setq b(read))
(write-line "After swapping...")
(setq a(+ a b))
(setq b(- a b))
(setq a(- a b))
(terpri)(princ "a=")(write a)
(terpri)(princ "b=")(write b)
(terpri)(format t "———————————————————————————————————————————")
Output
kodingwindow@kw:~$ clisp kw.lisp
———————————————————————————————————————————
Program to swap the given numbers
———————————————————————————————————————————
Enter the 1st number a=10
Enter the 2nd number b=20
After swapping...

a=20
b=10
———————————————————————————————————————————
kodingwindow@kw:~$ 
Advertisement