Pascal Code Examples: Arrays, Matrices, and Logic
Classified in Computers
Written on in
English with a size of 5.97 KB
Pascal Code Examples
1. String Search in Array
This program searches for a given name within an array of strings.
Program Pzim;
var
vet1: array[1..10] of string;
nome: string;
i, j: integer;
begin
j := 0;
for i := 1 to 10 do
begin
write('Enter the names: ');
readln(vet1[i]);
end;
write('Enter the name to be searched: ');
readln(nome);
for i := 1 to 10 do
begin
if (nome = vet1[i]) then
begin
writeln('FOUND');
j := j + 1;
end;
end;
if (j = 0) then
writeln('NOT FOUND');
end.
2. Merging Two Arrays
This program merges two arrays (vet1 and vet2) into a third array (vetx).
Program Pzim; var vet1: array[1..5] of integer; vet2: array[1..10] of integer; vetx: array[1..15] of integer;... Continue reading "Pascal Code Examples: Arrays, Matrices, and Logic" »