Coding Question-20

One comment on “Coding Question-20”


  • SUMIT

    #include
    using namespace std;

    void printPattern(int n){
    int m = n*3;
    int h = n/2;
    int fh = (m-3)/2;
    for(int i=1;i<=h;i++){

    int s=(m-(fh*2))/3;
    for(int i=1;i<=fh;i++){
    cout<<'-';
    }
    for(int i=0;i<s;i++){
    cout<<".|.";
    }
    for(int i=1;i<=fh;i++){
    cout<<'-';
    }
    cout<<endl;
    // break;

    fh=fh-3;
    }
    int welh = (m-7)/2;
    for(int i=0;i<welh;i++){
    cout<<'-';
    }
    cout<<"WELCOME";
    for(int i=0;i<welh;i++){
    cout<<'-';
    }
    cout<<endl;
    int second = 3;
    for(int i =1;i<=h;i++){
    for(int i=0;i<second;i++){
    cout<<'-';
    }
    int s = (m-(second*2))/3;
    for(int i=0;i<s;i++){
    cout<<".|.";
    }
    for(int i=0;i<second;i++){
    cout<<"-";
    }
    second+=3;
    cout<<endl;
    }
    }

    int main()
    {
    //it will accept odd numbers only
    printPattern(5);

    return 0;
    }