1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Pyramid Triangle in C#

Discussion in 'SAP and Others' started by Bagavathi, Feb 6, 2015.

  1. Bagavathi

    Bagavathi Active Member

    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    80
    Can any one tell by using for loop how print the following output on console in (C#)
    1
    121
    12321
    1234321
    123454321
    1234321
    12321
    121
    1
     
  2. yowancristo

    yowancristo Forum Advisor

    Messages:
    103
    Likes Received:
    10
    Trophy Points:
    305
    Location:
    Bangalore
    Hi,

    Below plsql code can give that result.

    Code (SQL):

    DECLARE

    r    NUMBER:= 1;

    BEGIN

        FOR i IN 1..5 LOOP            
            DBMS_OUTPUT.PUT_LINE(r*r);
            r := 1+ 10*r;    
        END LOOP;
       
        r := (r-1)/10;
       
        FOR i IN 1..4 LOOP
            r := (r-1)/10;  
            DBMS_OUTPUT.PUT_LINE(r*r);    
        END LOOP;
    END;
    /

     
    You can convert this logic into C program.
     
    Bagavathi likes this.