Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2012
    Posts
    4

    Unanswered: Multiplication of table.

    Hi,

    Im making a multiplication table for 5 and 6. im using this statement:

    declare
    a number(2):=5;
    b number(2):=6;
    c number(2);
    begin
    for c in 1..5
    loop
    dbms_output.put_line(a||'*'||c||' = '||a*c);
    dbms_output.put_line(b||'*'||c||' = '||b*c);
    end loop;
    end;
    /
    My required results are:
    5 * 1 = 5
    5 * 2 = 10
    5 * 3 = 15
    5 * 4 = 20
    5 * 5 = 25
    6 * 1 = 6
    6 * 2 = 12
    6 * 3 = 18
    6 * 4 = 24
    6 * 5 = 30

    Im getting

    5 * 1 = 5
    6 * 1 = 6
    5 * 2 = 10
    6 * 2 = 12.....

    Any idea how I can fix this?

    I tried:
    declare
    a number(2):=5;
    b number(2):=6;
    c number(2);
    begin
    for c in 1..5
    loop
    dbms_output.put_line(a||'*'||c||' = '||a*c);
    end loop;
    loop
    dbms_output.put_line(b||'*'||c||' = '||b*c);
    end loop;
    end;
    But this statement just hangs... it never shows the results.. froze my PC twice..

    THanks

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    declare
    a number(2):=5;
    b number(2):=6;
    c number(2);
    begin
    for c in 1..5
    loop
    dbms_output.put_line(a||'*'||c||' = '||a*c);
    end loop;
    for c in 1..5 
    loop
    dbms_output.put_line(b||'*'||c||' = '||b*c);
    end loop;
    end;
    I think you are missing a line.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •