how to fix exitcode 201?

Nabskyy picture Nabskyy · Feb 19, 2016 · Viewed 9k times · Source

I have a task to write a program in Pascal. When I run the program, the result was exitcode 201.

I don't know how to fix this error.

    program convertTime;
    uses crt;
    Type
            Jam = record
                  hh:integer ;
                  mm:integer ;
                  ss:integer;

    end;
    var
            J : Jam;
            P,totaldetik,sisa : integer;

    begin
            J.hh:= 16;
            J.mm:= 10;
            J.ss:= 34;

            write('masukkan waktu(menit): ');read(p);

            totaldetik:= (J.hh*3600) + (J.mm*60) + J.ss + (p*60);

            J.hh:= totaldetik div 3600;
            sisa:= totaldetik mod 3600 ;
            J.mm:= sisa div 60;
            J.ss:= sisa mod 60;

            writeln('total the time: ',J.hh,' Hour ',J.mm,' Minute ',J.ss,' second');
            readln;
    end.

Answer

andrewdotnich picture andrewdotnich · Feb 19, 2016

As seen in other questions, the error code 201 is a range check error. Put simply, a value's trying to be stored where it doesn't fit.

If, as in the linked question, you're using the Free Pascal Compiler, integer variables are 16-bit values – they can't go higher than 32,767.

Your totaldetik variable looks like it would often be higher than the limit for an integer value, so you'll need a larger variable to store it in. Try making totaldetik a longint instead.