Isnin, 15 Oktober 2018

Turbo pascal: Hello world


3 ulasan:

  1. program DataFiles;
    type
    StudentRecord = Record
    s_name: String;
    s_addr: String;
    s_batchcode: String;
    end;

    var
    Student: StudentRecord;
    f: file of StudentRecord;

    begin
    assign(f, 'students.dat');
    reset(f);
    while not eof(f) do

    begin
    read(f,Student);
    writeln('Name: ',Student.s_name);
    writeln('Address: ',Student.s_addr);
    writeln('Batch Code: ', Student.s_batchcode);
    end;

    close(f);
    end.

    BalasPadam
  2. program DataFiles;
    type
    StudentRecord = Record
    s_name: String;
    s_addr: String;
    s_batchcode: String;
    end;

    var
    Student: StudentRecord;
    f: file of StudentRecord;

    begin
    Assign(f,'students.dat');
    Rewrite(f);
    Student.s_name := 'John Smith';
    Student.s_addr := 'United States of America';
    Student.s_batchcode := 'Computer Science';
    Write(f,Student);
    Close(f);
    end.

    BalasPadam
  3. program DataFiles;
    type
    StudentRecord = Record
    s_name: String;
    s_addr: String;
    s_batchcode: String;
    end;

    var
    Student: StudentRecord;
    f: file of StudentRecord;

    begin
    assign(f, 'students.dat');
    reset(f);
    while not eof(f) do

    begin
    read(f,Student);
    writeln('Name: ',Student.s_name);
    writeln('Address: ',Student.s_addr);
    writeln('Batch Code: ', Student.s_batchcode);
    end;

    close(f);
    end.

    BalasPadam