VILL- DEBANDI, AMTA, HOWRAH PIN-711410 Phone-9836357266
12. Write a Prolog program to implement sumlist(List,Sum) so that Sum is the sum of a given list of numbers List.
sumlist([],0).
sumlist([H|T],R):-
sumlist(T,R1),
R is H+R1.
OUTPUT:
sumlist([6,9,70],X).
X = 85
No comments:
Post a Comment