Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help at making a tree trunk

pvnpvn Posts: 2Member
Hello to all
I am a beginner is pascal and i am trying to make a tree trunk that grows acording to the rest of the tree.
I already made the tree itself (here it is):

program Isosceles;
Uses Crt;
var num_lines, line:Integer;
procedure printline (num_esp, num_ast:Integer);
const aster='*';
esp=' ';
var counter:Integer;
begin
for counter:=1 to num_esp do
write(esp);
for counter:=1 to num_ast do
write(aster);
writeln
end;
begin (*Main program*)
writeln ('Height of the tree= ');
readln(num_lines);
for line:=1 to num_lines do
printline(num_lines-line,2*line-1);
readln;
end.


But now i am stuck and cant figure out how to make the tree trunk

I <------This part i want it to grow as the tree gets bigger(this part needs to be added at the bottom of the tree).



Help would be much appreciated

ps:I am usig Dev-Pascal 1.9.2.

Comments

  • quikcarlxquikcarlx Hollywood, FlPosts: 26Member
    I altered your program so that your subroutine could be a little more flexible. I dont know how you wanted to do the trunk so I made some assumptions.
    [code]program Isosceles;

    Uses Crt;

    var
    num_lines, line : Integer;
    trnk_spcs : integer;

    procedure printline ( num_esp, num_ast : Integer; tt : char );

    const
    esp = ' ';

    var
    counter : Integer;

    begin

    for counter := 1 to num_esp do
    write( esp );

    for counter := 1 to num_ast do
    write( tt );

    writeln
    end;

    begin (* Main program *)
    writeln( 'Height of the tree= ' );
    readln( num_lines );

    for line := 1 to num_lines do
    printline( num_lines - line, 2 * line - 1, '*' );

    trnk_spcs := num_lines - 1;

    for line := 1 to 4 do
    printline( trnk_spcs, 2, '|' );

    readln
    end.
    [/code]
  • pvnpvn Posts: 2Member
    Sorry but on my initial post i didnt explain myself to well, my bad.
    quikcarlx i want the tree trunk to grow as the tree gets bigger i have made some progress:

    program Isosceles;
    Uses Crt;
    var num_lines, line, temp:Integer;
    procedure printline (num_space, num_ast:Integer);
    const aster='*';
    esp=' ';
    var counter:Integer;
    begin
    for counter:=1 to num_space do
    write(esp);
    for counter:=1 to num_ast do
    write(aster);
    writeln
    end;
    Procedure trunk1;
    const esp=' ';
    trunk='I';
    Var counter:Integer;
    begin
    for counter:=1 to num_lines-1 do
    write(esp);
    writeln(trunk);
    end;
    begin (*main program*)
    writeln ('Height of the tree= ');
    readln(num_lines);
    for line:=1 to num_lines do
    printline(num_lines-line,2*line-1);
    for temp:=1 to num_lines do
    trunk1;
    readln;

    end.


    But i still havent figured out how to make the tree trunk get thicker as the tree gets bigger.

    Sorry taking so long to reply
  • erintecherintech Posts: 3Member
    quickcartx could you please contact me regarding a pascal bug I need help with? dennis dot lamb at gmail
  • erintecherintech Posts: 3Member
    quickcartx could you please contact me regarding a pascal bug I need help with? dennis dot lamb at gmail
  • erintecherintech Posts: 3Member
    quikcartx could you please contact me regarding a bug in a piece of Pascal code I am experiencing? dennis dot lamb at gmail
Sign In or Register to comment.