1 Replies - 514 Views - Last Post: 14 October 2013 - 02:38 PM Rate Topic: -----

#1 stuffandthings  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-October 13

runtime error in dev pascal

Posted 10 October 2013 - 10:46 PM

I know pascal is an ancient language, but we learn it as a basic fundamental for programming in our school.
I have to modulize a program for calculating loans with parameter procedures, and I am getting a runtime error.
This is the code (it's not done yet):
program Loantable;

var
   annualRate, interest, principal, balance : real;
   loan, monthlyRate, payment : real;
   noOfMonth : integer;

procedure heading;
begin
     write ('MONTH NUMBER':12, 'PAYMENT':12, 'INTEREST PAID':18);
     writeln ('PRINCIPAL PAID':19, 'BALANCE':12);
end;

procedure input (var x, y, z : real);
begin
     write ('Enter the amount of the loan: ');
     readln (x);
     writeln ('Enter the amount the person wishes to repay each month.');
     writeln ('Be certain that the payment desired is larger tha nthe first');
     write ('month''s interest: ');
     readln (y);
     write ('enter the annual interest rate in decimal: ');
     readln (z);
end;

procedure output (var a : integer; var b, c, d, e : real);
begin
     write (a:12, b:12:2, c:18:2, d:19:2);
     writeln (e:12:2);
end;

procedure calculation2 (var a1 : integer; var a2, a3, a4, a5, a6 : real);
begin
     while a3 > 0 do
     begin
          a1 := a1 + 1;
          a2 := a3 * a4;
          if a5 > a3 then
          begin
               a5 := a3 + a2;
               a6 := a3;
               a5 := 0;
          end
          else
          begin
               a6 := a5 - a2;
               a3 := a3 - a6;
          end;
     end;
     output (a1, a5, a2, a6, a3);
end;

begin {main}
      input (loan, payment, annualRate);
      writeln;
      writeln;
      heading;
      noOfmonth := 0;
      balance := loan;
      monthlyRate := annualrate / 12;
      calculation2 (noOfMonth, interest, balance, monthlyRate, payment, principal);
      readln;
end.


Immediately after entering the input, I'm getting the following error:
Runtime error 205 at 0x00401341
0x00401341
0x00401342
0x00401539

I've searched what error 205 means, and it means floating point overflow. But there's no number larger than 10000 in this program, and there's not many floating point calculations.

As you can see, I'm a complete beginner at programming.

Is This A Good Question/Topic? 0
  • +

Replies To: runtime error in dev pascal

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1305
  • View blog
  • Posts: 4,491
  • Joined: 19-February 09

Re: runtime error in dev pascal

Posted 14 October 2013 - 02:38 PM

Hi, you want to find where it falls over, you can use writes to show how far you have reached.

Your variables are not very descriptive (helpful in seeing the logic) eg a2, a3, a4, a5, a6.

In calculations2 it looks as if a5 might be able to increase and overflow.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1