0% found this document useful (0 votes)
4 views2 pages

Prolog Programs for Number Analysis

The document contains Prolog programs for various tasks including checking if a number is within a range, finding the minimum of two numbers, determining the maximum of three numbers, and checking if a number is odd or even. Each task is accompanied by the corresponding Prolog code. However, the outputs for each program are not provided.

Uploaded by

Sumit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Prolog Programs for Number Analysis

The document contains Prolog programs for various tasks including checking if a number is within a range, finding the minimum of two numbers, determining the maximum of three numbers, and checking if a number is odd or even. Each task is accompanied by the corresponding Prolog code. However, the outputs for each program are not provided.

Uploaded by

Sumit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ARTIFICIAL INTELLIGENCE LAB- DAY 2

1. Write a program in prolog to check whether a number is present within a


specific range or not.

CODE:

range(X,A,B):- X>A, X>B; X>B,X>A.

OUTPUT:

2. Write a program in prolog to find out the minimum number between two
number

CODE:

minimum (A,B) :- A=<B, write(‘Minimum is ’), write(A) .


minimum (A,B) :- A>B, write(‘Minimum is ’), write (B) .

OUTPUT:

3. Write a program in prolog to find out the maximum number between three
numbers.

CODE:
maximum (A,B,C) :- A>=B, A>=C, write (‘Maximum is ’) , write (A).
maximum (A,B,C) :- B>=A, B>=C, write (‘Maximum is ’) , write (B).
maximum (A,B,C) :- C>=A, C>=B, write (‘Maximum is ’) , write (C).

OUTPUT:

4. Write a program in prolog to find out whether a given number is odd or even.

CODE:

even_odd(A) :- A mod 2 =:= 0, write (‘ Number is even ’).


even_odd(A) :- A mod 2 =:= 0, write (‘ Number is even ’).

OUTPUT:

You might also like