C++ Program to Print Half Diamond Star Pattern

Write a C++ program to print the half diamond star pattern using for loop.

#include<iostream>
using namespace std;

int main()
{
	int i, j, k, rows;
     
    cout << "Enter Half Diamond Star Pattern Row = ";
    cin >> rows;

    cout << "Half Diamond Star Pattern\n"; 

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

    for(i = rows - 1; i > 0; i--)
    {
    	for(j = 1; j <= i; j++)
		{
            cout << "*";
        }
        cout << "\n";
    }	
 	return 0;
}
C++ Program to Print Half Diamond Star Pattern

This C++ example prints the half diamond pattern of a given symbol using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int i = 1, j, k, rows;
    char ch;
     
    cout << "Enter Half Diamond Star Pattern Row = ";
    cin >> rows;

    cout << "Enter Symbol for Half Diamond Pattern = ";
    cin >> ch;

    cout << "Half Diamond Star Pattern\n"; 

    while(i <= rows)
    {
        j = 1;
    	while( j <= i)
		{
            cout << ch;
            j++;
        }
        cout << "\n";
        i++;
    }	

    i = rows - 1;
    while( i > 0)
    {
        j = 1;
    	while( j <= i)
		{
            cout << ch;
            j++;
        }
        cout << "\n";
        i--;
    }	
 	return 0;
}
Enter Half Diamond Star Pattern Row = 12
Enter Symbol for Half Diamond Pattern = $
Half Diamond Star Pattern
$
$$
$$$
$$$$
$$$$$
$$$$$$
$$$$$$$
$$$$$$$$
$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$$
$$$$$$$$$$$$
$$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$
$$$$$$$$
$$$$$$$
$$$$$$
$$$$$
$$$$
$$$
$$
$