Advertisement
haunted_mind

l3e1evm

Nov 3rd, 2020
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.97 KB | None | 0 0
  1. program l3e1evm;
  2. {Ivan Ryvonenko, PM-12}
  3. {compute value of function f for arguments x:a<=x<=b with step h }
  4. {using functions and procedures}
  5. uses crt;
  6. var
  7.   a,b,h,x,f:real;
  8.  
  9. function sum:integer;
  10. var
  11.   s,i:integer;
  12. begin
  13.   s:=0;
  14.   for i:=1 to 12 do
  15.     s:=s+sqr(i-2);
  16.   sum:=s;
  17. end;
  18.  
  19. function compute_func(x:real):real;
  20. begin
  21.   if x<1 then
  22.     compute_func:=x*x*x-3*x+x*x
  23.   else if x<=5 then
  24.     compute_func:=(x*x+10-x)/(1+x)+sum
  25.   else
  26.     compute_func:=sqrt(sqr(x*x+1)+5);
  27. end;
  28.  
  29. begin
  30.   clrscr;
  31.   writeln;
  32.   writeln(sum);
  33.   write ('Enter [a,b] -> ');
  34.   readln(a,b);
  35.   write('Enter step h  -> ');
  36.   readln(h);
  37.  
  38.  
  39.  
  40.   writeln('Table of function values');
  41.   writeln('_______________________');
  42.   writeln('|x         |f         |' );
  43.   writeln('_______________________');
  44.   x:=a;
  45.   while (x<=b) do
  46.   begin
  47.     f:=compute_func(x);
  48.     writeln('|',x:6:2,'|',f:11:4,'|');
  49.     x:=x+h;
  50.   end;
  51.   writeln('_______________________');
  52.   readln;
  53. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement