Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Pascal Online

uses crt;
var i, checkNum: integer;
fileIn, fileOut: text;

function isPrimeNumber(n: integer): boolean;
begin
    isPrimeNumber:= true;
    for i := 2 to round(sqrt(n)) do 
        if (n mod i > 0) isPrimeNumber := false;
end;

begin
    //Paralel file handling 
    assign(fileIn, 'SND.dat');
    assign(fileOut, 'DSNT.dat');
    
    reset(fileIn);
    rewrite(fileOut);
    
    while not eof(fileIn) do
        begin
            read(fileIn, checkNum);
            if (isPrimeNumber(checkNum) = true) then
                begin
                    write(checkNum);
                    write(' ');
                end;
        end;
    close(fileIn);
    close(fileOut);
end.

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.