Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program var_27_task_2;
- {$APPTYPE CONSOLE}
- {$R *.res}
- uses
- System.SysUtils;
- var
- I : integer;
- SumOfNumbers : integer;
- N : integer;
- begin
- N := 0;
- While N <= 0 do
- begin
- try
- WriteLn('Enter the value of n : ');
- ReadLn(N);
- except
- on E: Exception do
- Writeln(E.ClassName, ': ', E.Message);
- end;
- if N<=0 then
- begin
- WriteLn('Input Error. Check if the data is correct.');
- end;
- end;
- for I := 1 to N do
- SumOfNumbers := SumOfNumbers + ((I-1)+I);
- WriteLn('Sum of all numbers = ', SumOfNumbers);
- Writeln('Press <enter> to quit...');
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement