ProLog Program for addition and multiplication of two numbers in Artificial Intelligence




% Prolog program for addition and multplication--------
% Alamgir Hossain
% CSE, JUST

go:- write('Enter first number : '),read(X),nl,
    write('Enter second number : '),read(Y),nl,
    addmul(X,Y).
addmul(X,Y):-
    S is X+Y,

    M is X*Y,

    write('Addition is : '),write(S),nl,

    write('Multiplication is : '),write(M).
% End of code
  
% Output---------


go.
Enter first number : 20.

Enter second number : 10.

Addition is : 30
Multiplication is : 200

2 comments: