Skip to main content

Pattern dimondHollow C++

        * 

      *   * 

    *       * 

  *           * 

*               * 

  *           * 

    *       * 

      *   * 

        * 


#include<iostream>
using namespace std;

int main()
{
      for(int i=0;i<9;i++)
    {  
        if(i<5){
       for(int j=0;j<=(2*i+4-i);j++)
        {
            if(j==(4-i) || j==(2*i+4-i))
            cout<<"* ";
            else
            cout<<"  ";
        }
        }
       
        else
        {
         
           for(int j=0;j<=(12-i);j++)
        {
            if(j==(i-4) || j==(12-i))
            {
                cout<<"* ";
            }
         
            else
            cout<<"  ";
        }
        }
        cout<<endl;
    }
    return 0;

}



Comments

Popular posts from this blog

7 features of OOPs

The 7 features of OOPs are as follows: 1. Incapsulation 2. Abstraction 3. Inheritance 4. Polymorphism 5. Object must be used 6. Massage passing : One object can interect with another object 7. Dynamic binding The most initial 4 are the basic OOPs features that is required.

Sieve Erotosthenes program in c++

  #include <bits/stdc++.h> using namespace std ; /* this program is for finding the prime number till the given number */ void primeSieve ( long long n ) {     long long prime [ n + 1 ] = { 0 };     for ( long long i = 2 ; i <= n ; i ++ )     {         if ( prime [ i ] == 0 )         for ( long long j = i * i ; j <= n ; j += i )         {             prime [ j ] = 1 ;         }             }     for ( long long i = 2 ; i <= n ; i ++ )     {         if ( prime [ i ] == 0 )         cout << i << " " ;     }         } int main () {     long long n ;     cin >> n ;     primeSieve ( n );     return 0 ; }

Array Data Structure