# Pascal help

Hi there, I'm taking Pascal in school and have run into troubles. I need to write a program to print a box that takes in the Length and Width of the box using symbols to create the box.

A sample output would be Length of 5, Width of 3 and Symbol of \$ would produce

\$\$\$\$\$
\$\$\$\$\$
\$\$\$\$\$

I've tried adapting another program to try and figure this problem out, but it isn't working to well. My current program is
[code]program Assignment2;
{Cole Gauthier 01/07/08}

uses wincrt;

var
Symbol:char;
Length,Width:integer;

procedure Draw(l:integer;w:integer;s:char);
var
Number_Length,Number_Width,Number_Stars:integer;
begin
for Number_Length:=1 to l do
begin
for Number_Stars:=1 to Number_Length do
write(s);
writeln
end;
end;

begin
write('Enter the length of the box. ');
write('Enter the width of the box. ');
write('Enter the symbol to be used in the design. ');
Draw(Length,Width,Symbol)
end.[/code]

Any pointers or suggestions or anything that will help me?

• : [code]: program Assignment2;
: {Cole Gauthier 01/07/08}
:
: uses wincrt;
:
: var
: Symbol:char;
: Length,Width:integer;
:
: procedure Draw(l:integer;w:integer;s:char);
: var
: Number_Length,Number_Width,Number_Stars:integer;
: begin
: for Number_Length:=1 to l do
: begin
[red]: for Number_Stars:=1 to Number_Length do[/red]
: write(s);
: writeln
: end;
: end;
:
: begin
: write('Enter the length of the box. ');
: write('Enter the width of the box. ');
: write('Enter the symbol to be used in the design. ');
: Draw(Length,Width,Symbol)
: end.[/code]:
:
: Any pointers or suggestions or anything that will help me?
:

Look at the two lines above. The inner loop looks good (red line), but you are using Number_Length which will create more of a triangle type of shape.
For the inner loop, just use [b]for Number_Stars:=1 to w do[/b].

Hope this helps, had to rewrite a bunch of stuff here as the font makes 1's and l's look alot the same!
Phat Nat
• : : [code]: : program Assignment2;
: : {Cole Gauthier 01/07/08}
: :
: : uses wincrt;
: :
: : var
: : Symbol:char;
: : Length,Width:integer;
: :
: : procedure Draw(l:integer;w:integer;s:char);
: : var
: : Number_Length,Number_Width,Number_Stars:integer;
: : begin
: : for Number_Length:=1 to l do
: : begin
: [red]: for Number_Stars:=1 to Number_Length do[/red]
: : write(s);
: : writeln
: : end;
: : end;
: :
: : begin
: : write('Enter the length of the box. ');
: : write('Enter the width of the box. ');
: : write('Enter the symbol to be used in the design. ');
: : Draw(Length,Width,Symbol)
: : end.[/code]: :
: :
: : Any pointers or suggestions or anything that will help me?
: :
:
: Look at the two lines above. The inner loop looks good (red line),
: but you are using Number_Length which will create more of a triangle
: type of shape.
: For the inner loop, just use [b]for Number_Stars:=1 to w do[/b].
:
: Hope this helps, had to rewrite a bunch of stuff here as the font
: makes 1's and l's look alot the same!
: Phat Nat
Yes, thanks so much. It worked perfectly. Without your help, I would have never figured that out