Program Integral;

Uses
      Crt;
Const
      A = - 0.5;
      B = Pi;
  AbsEr = 0.001;

 Var
         N : Word;
        x  : Extended;
        dx : Extended;
Old , Intg : Extended;

Function Ex ( X : Extended ) : Extended;
 Begin
  Ex := SIn ( X ) * Sin( X ) + Cos ( X )
 End;

Function Sign ( N : LongInt ) : Byte;
 Begin
  Sign := 0;
   If N <> 0 then Sign := N div Abs ( N ) ;
 End;

Procedure FNI;
 Begin
     N := 0;
     ClrScr;
     WriteLn('Finding step ... ');
   Repeat
     Old := Intg;
     Intg := 0;
    Inc ( N );
     dx := ( B - A ) / N;
      X := A;
    Repeat
     Intg := Intg + ( Ex( x ) ) * dx
      X := X + dx;
    Until X > B;
  Until Abs ( Intg - Old ) < AbsEr;
  WriteLn ( 'N=',N );
  WriteLn( 'Integral =', Intg );
 End;

Begin
FNI;
ReadKey;
End.