Jubecron Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Jubecron Forum

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

 

 Find the maximum of three numbers using Prolog

Go down 
AuthorMessage
Beezle
Elite Member
Elite Member
Beezle


Female
Number of posts : 547
Age : 34
Mood : Find the maximum of three numbers using Prolog Breezy
Points : 253
Registration date : 2008-03-02

Character sheet
Weapon: Chakrams
Class: Ninja Ninja
HP:
Find the maximum of three numbers using Prolog Left_bar_bleue50/50Find the maximum of three numbers using Prolog Empty_bar_bleue  (50/50)

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

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

Code:
% 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).
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
 
Find the maximum of three numbers using Prolog
Back to top 
Page 1 of 1
 Similar topics
-
» Prolog Exercise 1
» Prolog Lab 2
» prolog lab 3
» Prolog Lab 1
» Prolog Lab 5

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