Hello, I'm in a Pascal class and I'm having a hard time figuring out how to make my while... do and repeat... until statements work correctly in this program. Can someone show me what I'm doing wrong? program city;

var m,k,x : integer;

outfile : text;(*A building's roof*)

procedure roof;

begin

k := 1;

while k >= 5 do

//for k:= 1 to 5 do

begin

x := 4;

while x >= k do

//for x := 4 downto k do

begin

write (outfile, ' ');

x := x -1;

end;

begin

x := 1;

while x <= k*2-1 do

//for x := 1 to k*2-1 do

begin

write (outfile, '/');

x := x + 1;

end;

end;

writeln (outfile, '\');

end;

end;(*A building's top*)

procedure top;

var

k : integer;

begin

k := 3;

while k <= 3 do

//for k :=1 to 3 do

begin

x := 11;

while x <= 11 do

//for x := 1 to 11 do

begin

write (outfile,'*');

x := x + 1;

end;

k := k + 1;

end;

writeln (outfile);

end;(*A building's base*)

procedure base;

var k,x:integer;

begin

k := 1;

repeat

//for k := 1 to 4 do

begin

x := 1;

repeat

//for x := 1 to 3 do

write (outfile, '*');

until x > 3;

x := 1;

repeat

//for x := 1 to 5 do

write (outfile, ' ');

until x > 5;

x := 1;

repeat

//for x := 1 to 3 do

write (outfile, '*');

until x > 3;

writeln (outfile);

end;

until k > 4

end;(*A whole house*)

procedure house;

begin

roof;

top;

base

end;(*A federal building*)

procedure federal;

begin

roof;

k := 1;

repeat

//for k := 1 to 20 do

top;

until k > 20;

base;

end;

(*An arch*)

procedure arch;

begin

roof;

top;

k := 1;

repeat

//for k := 1 to 6 do

base;

until k >6

end;(*A yard*)

procedure yard;

var

k,r : integer;

begin

k := 1;

repeat

//for k := 1 to 5 do

begin

r := 1;

repeat

//for k := 1 to 11 do

write (outfile, '/\');

r := r + 1;

until r > 11;

writeln (outfile);

end;

k := k + 1;

until k > 5

end;(*A park*)

procedure park;

var

x : integer;

begin

x := 1;

repeat

//for x := 1 to 5 do

begin

x := 1;

repeat

//for x := 1 to 11 do

write (outfile, '|*%');

writeln (outfile);

until x > 11

end;

until x > 5

end;(*A high rise*)

procedure highrise;

var

m : integer;

begin

roof;

m := 1;

repeat

//for m:= 1 to 5 do

top;

base;

until m > 5

end;(*The people*)

procedure person;

begin

writeln (outfile, '"o"');

writeln (outfile, '-|-');

writeln (outfile, ' ^');

end;(*A city block*)

procedure cityblock;

var x : integer;

begin

for m := 1 to 3 do

begin

x := 1;

repeat

//for x := 1 to 6 do

yard;

until x > 6;

x := 1;

repeat

//for x := 1 to 2 do

highrise;

until x > 2;

x := 1;

repeat

//for x := 1 to 4 do

house;

until x > 4;

x := 1;

repeat

//for x := 1 to 11 do

park;

until x > 11;

federal;

x := 1;

repeat

//for x := 1 to 4 do

yard;

until x > 4;

x := 1;

repeat

//for x := 1 to 2 do

arch;

until x > 2;

x := 1;

repeat

//for x := 1 to 8 do

park;

until x > 8;

x := 1;

repeat

//for x := 1 to 5 do

person;

until x > 5;

x := 1;

repeat

//for x := 1 to 11 do

yard;

until x > 11

end;

end;(*The body of program*)

beginassign (outfile, 'mycity.txt');

rewrite (outfile);cityblock;

close (outfile);

readln;end.

I am very surprised you are learning Pascal, a dead programming language as ancient Greek and Latin, that may be of interest for software scientists only. Anyway // is a C comment and has no meaning in Pascal, almost in the Pascal I know and your loops are endless. E.G. procedure cityblock; var x : integer; begin for m := 1 to 3 do begin x := 1; repeat //for x := 1 to 6 do yard; until x > 6; x := 1; ....

would be codedprocedure cityblock; var x : integer; begin for m := 1 to 3 do begin x := 1; repeat x:= x+1; yard; until x > 6; x := 1; ....This is just a taste/tip as all of your code is far away to be correct. Another tip, use indentation as Pascal is higly structured and ... wbich Pascal are you coding in?

Ask Your Question

Weekly Poll

Do you think Monopoly should update its pieces?

Discuss in The Lounge

Poll History