Pages

Saturday, November 14, 2015

Pascal Program to Read in Even Numbers Into An Array

This program takes in only even numbers into an array of two rows and two columns. Here, a loop and conditional statement is used.

Program Eve;
Label 10;
Var
A : array[1..2,1..2] of integer;
I, j: integer;
Begin
For I:= 1 to 2 do
   For j:=  1 to 2 do
    Begin
10: readln (A[I , j]);
   If A[I , j] mod 2  < > 0 then goto 10
   Else
   End;
Begin
For I:= 1 to 2 do
For j:= 1 to 2 do
Writeln (A[I , j] );
Readln;
End.