Index | Home | Forums
Oracle PL/SQL Example 4-10 Using a Simple FOR..LOOP Statement

Example 4-10 Using a Simple FOR..LOOP Statement

DECLARE
  p     NUMBER := 0;
BEGIN
  FOR k IN 1..500 LOOP -- calculate pi with 500 terms
    p := p +  (  ( (-1) ** (k + 1) ) / ((2 * k) - 1) );
  END LOOP;
  p := 4 * p;
  DBMS_OUTPUT.PUT_LINE( 'pi is approximately : ' || p ); -- print result
END;
/


This page was generated on/at Feb 23,2008 00:20:12
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here




Index | Home | Forums
Oracle PL/SQL Example 4-10 Using a Simple FOR..LOOP Statement

Example 4-10 Using a Simple FOR..LOOP Statement

DECLARE
  p     NUMBER := 0;
BEGIN
  FOR k IN 1..500 LOOP -- calculate pi with 500 terms
    p := p +  (  ( (-1) ** (k + 1) ) / ((2 * k) - 1) );
  END LOOP;
  p := 4 * p;
  DBMS_OUTPUT.PUT_LINE( 'pi is approximately : ' || p ); -- print result
END;
/


This page was created by oracleabc.com on Feb 23,2008 00:09:02
General comments and questions regarding this document should be sent by email to info@oracleabc.com or post your comments here