Answer to Question #190570 in C++ for jainab

Question #190570

Write a PL/SQL program to find greatest of three numbers and print Fibonacci series up the largest number found.


1
Expert's answer
2021-05-08T01:12:17-0400


DECLARE 
    --initialize three numbers to check the greatest number 
    num_one number := 5; 
    num_two number := 7;
    num_three number := 2;
    greatest_num number;
    
    --declare variables to find fibonacci series
    ft number := 0;
    sd number := 1;
    temp number;
      
    n number;
    i number;


BEGIN 
    --find the greatest number 
    IF num_one > num_two 
       AND num_one > num_three THEN 
      greatest_num :=num_one;
    ELSIF num_two > num_one 
          AND num_two > num_one THEN 
      greatest_num :=num_two; 
    ELSE 
      greatest_num :=num_three; 
    END IF; 
 --end if condition
 
    n :=greatest_num;
    dbms_output.put_line('Fibonacci Series:');
  
--print the first and second numbers
    dbms_output.put_line(ft);
    dbms_output.put_line(sd);
  
-- loop i = 2 to n
    for i in 2..n
    loop
        temp:=ft+sd;
  
ft := sd;
sd := temp;
  
--print terms of fibonacci series
    dbms_output.put_line(temp);
end loop;
 
END; 


--End program  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS