0% found this document useful (0 votes)
165 views

Program Palindrom Pascal

The program checks if a user-input word is a palindrome by comparing the first and last characters, then the second and second last, and so on. It reads in a word from the user until it reaches a line break, stores it in an array, then loops through the array comparing the front and back characters. If all matches, it outputs that it is a palindrome, otherwise it is not a palindrome.

Uploaded by

frank co
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

Program Palindrom Pascal

The program checks if a user-input word is a palindrome by comparing the first and last characters, then the second and second last, and so on. It reads in a word from the user until it reaches a line break, stores it in an array, then loops through the array comparing the front and back characters. If all matches, it outputs that it is a palindrome, otherwise it is not a palindrome.

Uploaded by

frank co
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Program palindrom;

var
kata:array [1..100] of char;
i,a,b:integer;
m:boolean;
begin
write('Tuliskan kata yang ingin di cek : ');
i:=0;
repeat
i:=i+1;
read(kata[i]);
until kata[i]=#10;
i:=i-1;
if (i mod 2=0) then
begin
a:=0;
b:=i+1;
repeat
a:=a+1;
b:=b-1;
if (kata[a]=kata[b]) then
m:=true
else
m:=false;
until (a=(b-1)) or (m=false);
end else
begin
a:=0;
b:=i+1;
repeat
a:=a+1;
b:=b-1;
if (kata[a]=kata[b]) then
m:=true
else
m:=false;
until (a=(b-2)) or (m=false);
end;
if m=true then
writeln('Palindrom')
else
writeln('Jauh dari palindrom');
end.

You might also like