Prolog program for calculating weight of animals

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Define allweight(L, W), such that it is true iff % W is the total weight of all the animals in list L. % Assume that the weight of the animals is stored in % predicates of the form weight(X, N). weight(bird, 1). weight(dog, 20). weight(bear, 300). weight(elephant, 1000). allweight([],0). allweight([X],W):- weight(X,W). allweight([H|T],W):- allweight(T,Sum1),weight(H,Sum2),W […]

Read More

Operating system questions and solutions 2

1. Write a program named <print_num.c>, which should take one command-line argument called maxnum. Print_num should fork a child process, which prints the odd integers up to maxnum (inclusive), with space separating the numbers. At the same time, the parent process should print the even integers from 0 to maxnum (inclusive), with space separating the […]

Read More