•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 391,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,536 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:
Views: 2835 | Replies: 5
![]() |
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:
1
1 2
1 2 3
3 2 1
2 1
1
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:
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.
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:
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:
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
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



Linear Mode