Quick actions

cmd+k|ctrl+k

Navigation

Languages

Patterns

Snippet info

Language

Cpp

Visibility

public

Author

shilpimanchanda5

Created

2022-01-07T07:28:08.856634Z

Updated

2022-01-07T07:40:22.336113Z

#include <iostream>
using namespace std;

void printInvertedPyramid()
{
    int size=0;
    
    int blanks=0;
    
    cout<<"Input pyramid size"<<endl;
    cin >> size;
    
    for(int iR=0; iR < size; iR++)
    {
        for(int iC=0; iC<size-blanks;iC++)
        {
            cout<<"*";
        }
        blanks++;
        cout<<endl;
    }
}

void printHollowRectangle()
{
    int row, col;
    cout<<"Enter row and col "<<endl;
    cin >> row >> col;
    
    for(int iR=0; iR< row; iR++)
    {
        for(int iC=0; iC<col; iC++)
        {
            if(iR==0 || iR==row-1)
                cout<<"*";
            else
            {
                if(iC==0 || iC==col-1)
                    cout<<"*";
                else
                    cout<<" ";
            }
        }
        cout<<endl;
    }
        
}

int main() {
    cout << "Hello World!";
    printHollowRectangle();
    printInvertedPyramid();
    return 0;
}
INFO