hollow sqr c++

 #include<iostream>

using namespace std;


int main()

{

    int r , c ;

    int i , j;

    cout<<"rows : ";

    cin>>r;

    cout<<"col : ";

    cin>>c;

    for (i=1;i<=r;i++){

        for (j=1;j<=c;j++){

            if (i==1 || i==r){

                cout<<"*";

            }

            else if(j==1 || j==c){

                cout<<"*";

            }

            else {

                cout<<" ";

            }

        }

        cout<<endl;

    }


    return 0;

}


Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings