Sunday, October 14, 2018

Pascal program to print multiplication table using all repetitions (while, for, repeat .. until)

Pascal program to print multiplication table using repetition "for" 
{define variables}
var
x, i: Integer;

begin {start main program}
     write('Please input formula Number?: '); {message to display to user}
     readln(x);
     for i:= 1 to 12 do
          writeln(x, ' * ', i, ' = ', x * i);
     writeln('Press enter key to close');
     readln;
end.    {end main program}   


Pascal program to print multiplication table using repetition "while"
var
x, i: Integer;
begin
     Write('Please input formula number? ');
     Readln(x);
     i:=1;
     while i<=12 do
     begin
           Writeln(x, ' * ', i, ' = ', x * i);
           i:=i+1;
     end;
Writeln('Press enter key to close');
Readln;
end.   

Pascal program to print multiplication table using repetition "repeat until"
var
x, i: Integer;
begin
     Write('Please input formula number? ');
     Readln(x);
     i:=1;
     repeat
           Writeln(x, ' * ', i, ' = ', x * i);
           i:=i+1;
     until i>12;
Writeln('Press enter key to close');
Readln;
end.


Output screen of the above Pascal Program (all the programs will give same output)

MultiplicatinTableUsingPascalProgram

1 comment: