Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

loop example PL/SQL

DECLARE
   n NUMBER;
   average NUMBER :=0 ;
   sum NUMBER :=0 ;
   count NUMBER :=0 ;
BEGIN
   -- Take input from user
   n := &input_number;
   WHILE(n<>0)
       LOOP
           -- Increment count to find total elements
           count := count+1;
           -- Sum of elements entered
           sum := sum+n;
           -- Take input from user
           n := &input_number;
       END LOOP;
   -- Average calculation
   average := sum/count;
   DBMS_OUTPUT.PUT_LINE(‘Average of entered numbers is ’||average);
END;
Source by www.interviewbit.com #
 
PREVIOUS NEXT
Tagged: #loop
ADD COMMENT
Topic
Name
7+7 =