First we need to identify the upper value or not.Prolog program needs to check character as per ascii value.If it's value less than 90 but greater than 65.That's value of uppercase identification.The uppercase identify with help of ascii value that is define for find each character's ascii value.The ascii value find using the readchar() command.The command give the ascii value of any character.
First we need to identify the lower value or not.Prolog program needs to check character as per ascii value between 97 to 122 or not.If it's value less than 122 but greater than 97.That's value of lowercase identification.The lowercase identify with help of ascii value that is define for find each character's ascii value.The ascii value find using the readchar() command.The command give the ascii value of any character.
First we need to identify the digit value or not.Prolog program needs to check character as per ascii value between 48 to 57.If it's value less than 57 but greater than 48.That's value of digit identification.The digit value identify with help of ascii value that is define for find each character's ascii value.The ascii value find using the readchar() command.The command give the ascii value of any character.
The below program identify the value is uppercase,lowercase or digit value.So,see program below:
predicates
goh check(char,string)
clauses
go:-
write("Enter the string:"),
readchar(S),
check(S,X),
write("\n",S," is",X).
check(S,X):-
S>=65,S<=90,
X=" Uppercase\n".
check(S,X):-
S>=97,S<=122,
X=" Lowercase.".
check(S,X):-
S>=48,S<=57,
X=" Digit.".