Example
Input
Enter rows: 5
Output
***** ***** ***** ***** *****
Required Knowledge
Basic C++ programming, For loop, Nested loop
Making Solid Rhombus is similar to making a solid square rather than the concept that for each ith row we have n-i blank spaces before stars as:
– – – ****
– – ****
– ****
****
Program
#include <iostream>
using namespace std;
/*
* Siddharth Goyal
* Chandigarh Engineering College, Landran
*
*/
int main()
{
int i, j, rows;
cout<<"Enter rows: ";
cin>>rows;
for(i=1; i<=rows; i++)
{
/* Print trailing spaces */
for(j=1; j<=rows - i; j++)
{
printf(" ");
}
/* Print stars after spaces */
for(j=1; j<=rows; j++)
{
cout<<"*";
}
/* Move to the next line */
cout<<"\n";
}
return 0;
}
Output