Hi guys.
I have an assignment due soon and in the program, we have to display shapes, and calculate their areas, perimeters etc.
The problem I'm having is with the rectangle. The triangle and square work fine...
Code:If sel = 1 then {To display the triangle on screen} For line_number :=1 to tri_side do Begin For pos:= 1 to (tri_side - line_number) do Begin Write(' '); End; For pos:= pos + 1 to (pos + ((2 * line_number) - 1)) do Begin Write('*'); End; For pos:= pos + 1 to ((2 * tri_side) - 1) do Begin Write(''); End; Writeln; End; It comes out like... * *** ***** ******* *********Could someone who may know this please help me along? I need to know how to display the rectangle giving the input of rec_width and rec_length.Code:If sel = 1 then {To display the square on screen} For line_number :=1 to sqr_side do Begin For pos:= 1 to sqr_side do Begin Write('* '); End; Writeln; End; It comes out like ********* ********* ********* *********
Thanks guys!
Bookmarks