| | |
Turbo pascal Homework..
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi guys 
I've just learn programming in turbo pascal, and my teacher made an assignment to make pyramid of numbers as this:
so far i've only come up as this:
this is the output:
--------------------(2)------------------
And another one:
Make the word : "Hello" to "olleH"
do I have to use arrays on this one?
I'm totally blank on this one , please point me to the right direction..
----------------------------------------
Can anybody help me?
thanks..

I've just learn programming in turbo pascal, and my teacher made an assignment to make pyramid of numbers as this:
Pascal and Delphi Syntax (Toggle Plain Text)
1 1 2 1 2 3 3 2 1 2 1 1
Pascal and Delphi Syntax (Toggle Plain Text)
uses crt; var i,j,k : byte; begin clrscr; for i := 1 to 3 do begin for j := 3 downto i do begin inc (k); if i = 2 then k:=3; gotoxy(i+k,j); write(i); end; end; readkey; end.
this is the output:
Pascal and Delphi Syntax (Toggle Plain Text)
1 1 2 1 2 3
And another one:
Make the word : "Hello" to "olleH"
do I have to use arrays on this one?
I'm totally blank on this one , please point me to the right direction..
----------------------------------------
Can anybody help me?
thanks..
for the first one, you could use this:
for the second one, there are a lot of methods to reach the result.
thirst one I can think of is:
as you can see, no explicit <arrays>
strings are actually arrays.
you could also do it with just one variable. the one with the text.
Pascal and Delphi Syntax (Toggle Plain Text)
uses crt; var k,i,j:integer; begin clrscr; readln(k); for i:=1 to k do begin for j:=1 to k-i do write(' '); for j:=1 to i do write(j,' '); writeln; end; for i:=k downto k do begin for j:=1 to k-i do write(' '); for j:=i downto 1 do write(j,' '); writeln; end; readkey; end.
for the second one, there are a lot of methods to reach the result.
thirst one I can think of is:
Pascal and Delphi Syntax (Toggle Plain Text)
var s:string; i:byte; begin readln(s); for i:=length(s) downto 1 do write(s[i]); writeln; end.
strings are actually arrays.
you could also do it with just one variable. the one with the text.
My teacher made me make an inversed pyramid..
Heres the code, if anyone needs it:
Heres the code, if anyone needs it:
Pascal and Delphi Syntax (Toggle Plain Text)
uses crt; const pert ='Batas diamond: '; var i, j, k,bts: Byte; begin gotoxy(30,5);write(pert); gotoxy(30+length(pert),5);read(bts); for i := bts downto 1 do begin inc(k); gotoxy(1, k); for j := 1 to i do begin Write(j); end; end; k :=0; for i := 1 to bts do begin Inc(k); gotoXY(1,k + bts); for j := 1 to i do begin Write(j); end; end; k := 0; for i := bts downto 1 do begin Inc(k); gotoxy(k + bts,k); for j := i downto 1 do begin Write(j); end; end; k := 0; for i := bts downto 1 do begin Inc(k); gotoXY(k + bts,i + bts); for j := i downto 1 do begin Write(j); end; end; readkey; end.
![]() |
Similar Threads
- calnder programming in turbo pascal With Text & background !! (Pascal and Delphi)
- help needed to print from turbo pascal (Pascal and Delphi)
- Turbo pascal homework (Pascal and Delphi)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: real variable type question
- Next Thread: resource file error
| Thread Tools | Search this Thread |






