Search
 
SCRIPT & CODE EXAMPLE
 

CPP

diamond star pattern in cpp

include <bits/stdc++.h>             //       *
using namespace std;                //      ***
int main()                          //     *****
{                                   //      ***
    int n, i, j;                    //       *
	cin>>n;
    int m = n;
 // FOR UPPER Half
	for(i=1; i<=n; i++)
	{
		for(j=0; j<m-1; j++)
			cout<<" ";

		for(j=0; j<2*i-1; j++)
			cout<<"*";

		cout<<"
";
		m--;
	}
  // FOR LOWER Half
	for(i=n-1; i>=1; i--)
	{
		for(j=0; j<m+1; j++)
			cout<<" ";
		for(j=0; j<2*i-1; j++)
			cout<<"*";
		    cout<<"
";
		m++;
	}
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: a c++ program to set a countdown timer 
Cpp :: select one random element of a vector in c++ 
Cpp :: underline in latex 
Cpp :: How to make two dimensional string in c++ 
Cpp :: qt qstring to float 
Cpp :: setprecision in c++ 
Cpp :: c++ reverse vector 
Cpp :: vhdl integer to std_logic_vector 
Cpp :: UNIX c++ delay 
Cpp :: clear file before writing c++ 
Cpp :: check if intent has extras 
Cpp :: 2114. Maximum Number of Words Found in Sentences leetcode solution in c++ 
Cpp :: struct and return functions in c++ 
Cpp :: eosio parse string 
Cpp :: ue4 ftext c++ 
Cpp :: search update delete files in c++ 
Cpp :: c++ nth substr 
Cpp :: c++ save typeid 
Cpp :: c++ vector combine two vectors 
Cpp :: prints all the keys and values in a map c++ 
Cpp :: c++ compare strings ignore case 
Cpp :: qt float to qstring 
Cpp :: number to binary string c++ 
Cpp :: how to declrae an array of size 1 
Cpp :: cout was not declared in this scope 
Cpp :: spicoli 
Cpp :: 2d vector c++ declaration 
Cpp :: c++ check first character of string 
Cpp :: if even number c++ 
Cpp :: how to open and read text files in c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =