Advertisement
rayhanf

setlength

Apr 9th, 2023 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.31 KB | Source Code | 0 0
  1. program cariRerata;
  2. uses crt;
  3.  
  4. var
  5.     x: array of integer;
  6.     i, n, sum: integer;
  7.  
  8. begin
  9.     clrscr;
  10.     write('Masukkan n: '); readln(n);
  11.     setlength(x, n);
  12.  
  13.     sum := 0;
  14.     for i:=1 to n do begin
  15.         write('Bil ke-', i, ': '); readln(x[i-1]);
  16.         sum := sum + x[i-1];
  17.     end;
  18.     writeln('Rerata: ', sum/n:0:2);
  19. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement