Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why it isn't work? It's said main.pas(12,1) Fatal: Syntax error, "BEGIN" expected but "identifier D" found

0 votes
asked May 10, 2020 by Nhân CFM (120 points)
program Hello;
uses crt;
d,i,vt,dem:integer;
begin
clrscr;
write('nhap xau S:'); readln(s);
d:=length(s);
st:="";
for i:=1 to d do
if s[i] in ['0'..'9'] then st:=st+s[i];
writeln('Xau moi vua duoc tao la: ',st);
for i:=1 to d do
if (s[i]<>'a') and (s[i]<>'b') then write(s[i]);
writeln;
st1:='tin';
vt:=pos(st1,s);
if vt=0 then writeln(s)
else
begin
inc(dem);
a[dem]:=vt;
end;
if dem>0 then
begin
for i:=1 to dem do
begin
delete(s,a[i],3);
insert('pascal',s,a[i]);
end;
writeln;
end;
readln;
end.

3 Answers

+1 vote
answered May 12, 2020 by Info Ipse (200 points)

use var beffor  variables :
 

var

d,i,vt,dem:integer;

0 votes
answered May 12, 2020 by Info Ipse (200 points)
and you must make s and str in variables:

s,st:string[255];

also

you cant make

st="" in pascal it's forbiden
0 votes
answered May 13, 2020 by Juergen (300 points)
Variable declarations in pascal need a var keyword.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...