Fibonacci Series using pl/sql

Write pl/sql code to generate Fibonacci Series

8 comments:

  1. Id:201330499

    1 declare
    2 a number(5):=0;
    3 b number(5):=1;
    4 fib number(5):=0;
    5 i number(5);
    6 begin
    7 for i in 0..10 loop
    8 fib:=a+b;
    9 dbms_output.put_line('seris is='||fib);
    10 a:=b;
    11 b:=fib;
    12 end loop;
    13 end;
    14 /

    ReplyDelete
  2. Name:Fatema binte Shakir
    ID:201410038
    1 declare
    2 a number(5):=0;
    3 b number(5):=1;
    4 fib number(5):=0;
    5 i number(5);
    6 begin
    7 for i in 0..10 loop
    8 fib:=a+b;
    9 dbms_output.put_line('seris is='||fib);
    10 a:=b;
    11 b:=fib;
    12 end loop;
    13 end;
    14 /

    ReplyDelete
  3. declare
    a number(4):=0;
    b number(4):=1;
    c number(4):=0;
    i number(4);
    begin
    dbms_output.put_line(a);
    dbms_output.put_line(b);
    for i in 3..20 loop
    c:=a+b;
    dbms_output.put_line(c);
    a:=b;
    b:=c;
    end loop;
    end;
    /

    ReplyDelete

  4. 1 declare
    2 x number(5):=5;
    3 y number(6):=6;
    4 z number(7):=5;
    5 f number(5);
    6 begin
    7 dbms_output.put_line(x);
    8 dbms_output.put_line(y);
    9 for f in 0..10 loop
    10 z:=x+y;
    11 dbms_output.put_line(z);
    12 x:=y;
    13 y:=z;
    14 end loop;
    15 end;
    /

    ReplyDelete
  5. 1 declare
    2 a number(5):=&a;
    3 b number(6):=&b;
    4 c number(7):=&c;
    5 f number(5);
    6 begin
    7 dbms_output.put_line(a);
    8 dbms_output.put_line(b);
    9 for f in 0..10 loop
    10 c:=a+b;
    11 dbms_output.put_line(c);
    12 a:=b;
    13 b:=c;
    14 end loop;
    15 end;
    /

    ReplyDelete
  6. declare
    num1 number(5):=0;
    num2 number(5):=1;
    fibo number(5):=0;
    j number(5);
    begin
    for j in 0..10 loop
    fibo:=num1+num2;
    dbms_output.put_line('fibonacci series is:' ||fibo
    );
    num1:=num2;
    num2:=fibo;
    end loop;
    end;
    /

    ReplyDelete
  7. declare
    a number(2);
    b number(2);
    fib number(5);
    begin
    a:=0;
    b:=1;
    for i in 1..10 loop
    fib:=a+b;
    dbms_output.put_line(fib);
    a:=b;
    b:=fib;
    end loop;
    end;

    ReplyDelete
  8. declare
    n number(5);
    i number(5):=0;
    next number(5);
    first number(5):=0;
    second number(5):=1;
    procedure fibo(n number)
    as
    begin
    next:=first+second;
    first:=second;
    second:=next;
    dbms_output.put_line(next);
    end;

    begin
    dbms_output.put_line('Enter the number of terms:');
    n:=&n;
    for i in 0..n loop
    if i<=1 then
    dbms_output.put_line(i);
    else
    fibo(i);
    end if;
    end loop;
    end;
    /


    ReplyDelete

Popular Posts