C++ program to print rectangle star pattern

The rectangle star pattern problem is similar to the square star pattern problem. Click here to view square star pattern problem

Example

Input:

     Enter number of rows: 5
     Enter number of columns: 3 

Output:

***
***
***
***
***

Required Knowledge

Basic C++ programming, For loop, Nested loop

Program

#include <iostream>
using namespace std;
/*
    * Siddharth Goyal
    * Chandigarh Engineering College, Landran
    *
*/
int main()
{
    int i, j, rows, columns;

    cout<<"Enter number of rows: ";
    cin>>rows;
    cout<<"Enter number of columns: ";
    cin>>columns;

    for(i=1; i<=rows; i++)
    {
        for(j=1; j<=columns; j++)
        {
            cout<<"*";
        }
        
        cout<<"\n";
    }
    return 0;
}

Output

  • Save

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap