How i can get in result this picture: Click Here
for now my code is:

program cikls;
label m;
var
a:byte;
begin
write('Ievadiet veselu skaitli:');
readln(a);
if a<1 then goto m;
repeat
  writeln(a);
  a:= a-1;
until a = 0;
m:
readln;
end.

When i runit it make numbers counting down. I have change number to this symbols *.

At line 10 your variable "a" tells you how many asterisks to print. SO you can use a second loop there. Execute the new loop "a" times and print a single asterisk each time.

And lose the GOTO. There are times when a GOTO is acceptable, even preferable, to the structured equivalent. This is not one of them.

Has your course covered either while loops, or for loops, yet? It would be very unusual for a class to cover repeat...until without covering those first.

For a quick thumbnail sketch: while is pre-conditional indefinite loop, that is to say, is repeats based on a conditional test that is first tested at the start of the loop.

     a := 0;

     while a < 1 do
     begin
         readln(a);
     end;

It is basically the same as repeat...until, except that repeat...until always runs the body of the loop at least once.

By contrast, the for loop is a definite loop, meaning it repeats a fixed number of times - either counting up, or counting down.

For example, counting from 0 to 10 would be:

     for i := 0 to 10 do
     begin
         { do something here }
     end;

while counting down is

    for j := 10 downto 0 do
    begin
        { do something else here }
    end;

Note also that you can have nested loops, that is, a loop with another loop inside of it:

    For j := a DownTo 1 Do
    Begin
        For i : = 1 To j Do
        Begin
            {  do something here }
        End;
    End;

You will also notice that Pascal is case-insensitive, meaning that for, For, FOR, fOr, etc... are all the same keyword. You can use the style you want, or at least the one your professor requires, but you want to know that it can vary like this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.