This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 22nd, 2012  |  syntax: None  |  size: 1.44 KB  |  views: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. program ex27;
  2.  
  3. uses
  4.   sysutils;
  5. var
  6.   numbers:array [1..2] of integer;
  7.   loopcounter, loopcounter1, i, loopcounter2, startat, answer, dummy : integer;
  8.   valid: boolean;
  9.   input : string;
  10.  
  11. procedure getinput;                                          //WORKS
  12. begin
  13. //initialise
  14.   for i := 1 to 2 do
  15.       numbers[i]:= 0;
  16.  
  17.   for loopcounter:=1 to 2 do
  18.     begin
  19.       repeat
  20.         write('Please enter the number: ');
  21.         readln(input);
  22.         valid:=true;
  23.  
  24.         if length(input)=0 then
  25.           valid:=false
  26.         else
  27.         begin
  28.           if input[1]='-' then
  29.             startat:=2
  30.           else
  31.             startat:=1;
  32.  
  33.             for loopcounter2:=startat to length(input) do
  34.               begin
  35.                 if not (input[loopcounter2] in ['0'..'9']) then
  36.                   valid:=false;
  37.                   break;
  38.               end;
  39.           end;
  40.         if not valid then
  41.           writeln('this is not a valid integer.');
  42.       until valid;
  43.       numbers[loopcounter1]:=strtoint(input);
  44.     end;
  45. end;
  46. procedure calculatefibonacci(numbers: array of integer);
  47. begin
  48.   for loopcounter:=1 to 2 do
  49.     dummy:=numbers[1]+numbers[2];
  50.   write(numbers[2]);
  51.   begin
  52.       answer:=numbers[1]+numbers[2];
  53.       writeln(answer);
  54.       writeln;
  55.   end;
  56. end;
  57. procedure closeprogram;
  58. begin
  59. write('Press enter to close');
  60. readln;
  61. end;
  62.  
  63. begin
  64.   getinput;
  65.   calculatefibonacci(numbers);
  66.   closeprogram;
  67. end.
clone this paste RAW Paste Data