C++ program to print square star pattern

Example

Input

 Input number of rows: 5

Output

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

Knowledge Required

  • Nested Loops
  • conditional Statements

Program to print square star pattern

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

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

    for(i=1; i<=N; i++){
        for(j=1; j<=N; j++){
            cout<<"*";
        }       
        cout<<"\n";
    }
    return 0;
}
Output
Enter number of rows:
*****
*****
*****
*****
*****
  • Save

Leave a Reply

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

Share via
Copy link
Powered by Social Snap