Jubecron Forum

The JUBECRON forum - Jamaican Chat, Dating, Games, Anime, and just meeting people.
HomePortalFAQSearchRegisterMemberlistUsergroupsLog in

Share | 

 Find the maximum of three numbers using Prolog

Go down 
Elite Member
Elite Member

Number of posts : 547
Age : 28
Mood :
Points : 253
Registration date : 2008-03-02

Character sheet
Weapon: Chakrams
Class: Ninja Ninja
50/50  (50/50)

PostSubject: Find the maximum of three numbers using Prolog   Fri Oct 29, 2010 8:16 pm

This code can be modified to find the maximum of any number of inputs.

% Author: Claudia-Ann Gray
% Date: 10/29/2010

max:-write('Enter first number'),nl, read(Num1),nl,write('Enter second number'),
                  nl,read(Num2),nl,write('Enter third number'),nl,read(Num3),
find_max(Num1,Num2,Num3):-(Num1>Num2,Num1>Num3->nl,write(Num1),write(' is the biggest'),!);
                  (Num2>Num3->nl,write(Num2),write(' is the biggest'),!);nl,write(Num3),
                  write(' is the biggest'),!.
Back to top Go down
View user profile
Find the maximum of three numbers using Prolog
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Jubecron Forum :: School :: Schools (General)-
Jump to: