The following are the programs which can perform different arithmetic operations in Prolog
To Sum Numbers.
sum:-
write('Type your First Number '),
read(X),
write('Type Your 2nd Number '),
read(Y),
S is X+Y,
write('The Sum of your numbers is = '),write(S),nl.
To Subtract Numbers
sub:-
write('Type your first Number '),
read(X),
write('Type your 2nd Number '),
read(Y),
D is X-Y,
write('When we subtract your Numbers we get ='),write(D),nl.
To Divide Numbers
divide:-
write('Type your First Number '),
read(X),
write('Type Your 2nd Number '),
read(Y),
Di is X/Y,
write('when we divide your numbers we get = '),write(Di),nl.
To Multiply Numbers
multiply:-
write('Type your First Number '),
read(X),
write('Type Your 2nd Number '),
read(Y),
M is X*Y,
write('The Multiply your numbers we get = '),write(M),nl.
No comments:
Post a Comment