•
•
•
•
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 423,398 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 4,557 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: Programming Forums
Views: 407 | Replies: 1
![]() |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
This is the Question:-
3)Implement oon pascal a program to produce the following output:-
The number of rows to be printed on the screen should be specified buy the user nad you have to use for loops.
i have done the bit where it just outputs:-
*
**
***
****
*****
but the bit i can do is for the user to specify the number of lines there are?
this is my programming language for the bit i have done:-
3)Implement oon pascal a program to produce the following output:-
* ** *** **** *****
The number of rows to be printed on the screen should be specified buy the user nad you have to use for loops.
i have done the bit where it just outputs:-
*
**
***
****
*****
but the bit i can do is for the user to specify the number of lines there are?
this is my programming language for the bit i have done:-
language Syntax (Toggle Plain Text)
Program Question_3; Uses Wincrt; Var x : integer; Begin For x:= 1 to 1 do Begin write('*') End; writeln; For x:= 1 to 2 do Begin write('*') End; writeln; For x:= 1 to 3 do Begin write('*') End; writeln; For x:= 1 to 4 do Begin write('*') End; writeln; For x:= 1 to 5 do Begin write('*') End; writeln; End.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
Any time you find that you are repeating yourself, that is a good thing to turn into a loop.
First, figure out what changes each time and what stays the same. The thing that changes is a variable.
In your examples (done with [inlinecode] so that I can highlight something) they are all the same except for one thing:
The only thing that changes each time is the number of times you go through the for loop. The first time it is 1, the second time it is 2, the third time it is 3, etc. Fortunately, you can use a for loop to count numbers 1, 2, 3, etc. (It is OK to have a loop inside another loop.)
That should be enough to help. Good luck.
First, figure out what changes each time and what stays the same. The thing that changes is a variable.
In your examples (done with [inlinecode] so that I can highlight something) they are all the same except for one thing:
For x:= 1 to 1 do Begin write('*') End; writeln;The only thing that changes each time is the number of times you go through the for loop. The first time it is 1, the second time it is 2, the third time it is 3, etc. Fortunately, you can use a for loop to count numbers 1, 2, 3, etc. (It is OK to have a loop inside another loop.)
That should be enough to help. Good luck.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Pascal starter. (Pascal and Delphi)
- Where to head with C++ programming? (IT Careers and Business)
- Arithmetic Exceptions and exception-handling statements (Java)
- Pseudo-Pascal Question: Need Help!! (Pascal and Delphi)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Prblem with removing duplicates entries in a list.
- Next Thread: Point me in the right direction



Linear Mode