Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Tuesday 13 March 2018

PL/SQL function to view maximum of 3 numbers

In this code the input is given by the user.



DECLARE 
   a number := &enter_first_Number; 
   b number := &Enter_second_number ; 
   c number := &enter_third_number;  
   d number;
FUNCTION findMax(x IN number, y IN number, z IN number)  
RETURN number 
IS 
    w number; 
BEGIN 
   IF x > y AND x > z THEN 
      w:= x; 
   ELSE IF y>x AND y>z THEN
      w := y;
   ELSE IF z>x AND z>y THEN
      w := z;
   END IF;
   END IF;  
   END IF;
   RETURN w; 
END;

BEGIN 
    
   d := findMax(a, b, c); 
   dbms_output.put_line(' Maximum is ' || d); 
END; 

     

No comments:

Post a Comment