Write a program in Pascal. Print the penultimate word in the line entered by the user.

program word;
var s: string;
c: char;
l, k, m: integer;
begin
writeln (‘Enter a string with spaces between words’);
readln (s);
l: = length (s);
k: = 0;
while k <1 do // Find the position of the first space from the end
begin
c: = s [l];
if c = ” then k: = l;
l: = l – 1;
end;
m: = 0;
while m <1 do // Find the position of the second space from the end
begin
c: = s [l];
if c = ” then m: = l;
l: = l – 1;
end;
// display letters between the next spaces
for i: integer: = m + 1 to k-1 do write (s [i])
end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.