C++ Program to print Mirrored Rhombus Star Pattern

Example

Input :

Input rows: 5

Output :

Enter number of rows:5
*****
 *****
  *****
   *****
    *****

Required knowledge

Basic C programming, For loop, Nested loop

C++ Program to print mirrored rhombus star pattern

#include <iostream> 
/*
     * Siddharth Goyal
     * Chandigarh Engineering College, Landran
     *
*/
int main() {
     int i, j, N;
     /* Input number of rows from user */
     cout<<"Enter rows: ";
     cin>>N;
     for(i=1; i<=N; i++)
     {
         /* Print trailing spaces */
         for(j=1; j<i; j++)
         {
             cout<<" ";
         }
         for(j=1; j<=N; j++)
         {
             cout<<"*";
         }
         cout<<"\n";
     }
     return 0;
 } 

Output:

Enter rows: 5
*****
 *****
  *****
   *****
    *****
  • Save

Leave a Reply

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

Share via
Copy link
Powered by Social Snap