20_09

Write a Prolog program to implement sumlist(List,Sum) so that Sum is the sum of a given list of numbers List.

 Source Code :

 

listsum([],0).

listsum([H|T],R) :-

    listsum(T,S),

    R is H+S.

 

Output :

Prolog program to implement sumlist(List,Sum) so that Sum is the sum of a given list of numbers List


No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...