Thursday, 6 August 2015

GRK Web

We are a passionate Computer Science Engineering Students who believe in our dreams.
We are application Developers who develop awesome applications for PC and Mobile platforms. 
We build the Future Today.
Our Official website : grkweb.com
Facebook Page : facebook.com/grkweb

Wednesday, 5 August 2015

C++ Diamond Pattern

C++ program to print the diamond pattern using '#' symbols. In this program two for loops are used to print the pattern. The first loop prints the upper part to the diamond ( triangle part ). The second for loop prints the lower part of the diamond (an inverted triangle ) . By combining both of the triangles an diamond pattern structure is formed.

PROGRAM CODE:

 #include<iostream>  
 using namespace std;  
  int main()  
  {  
    int i,j,k=1,s=6,l;  
    for(i=0;i<5;i++,k-=2,s-=1)  
    {  
      for(l=s-1;l>=0;l--)  
      cout<<' ';  
      for(j=k;j<0;j++)  
        cout<<"#";  
      cout<<endl;  
   }  
 k = 9;  
 s = 0;  
 for(i=0;i<5;i++,k-=2,s+=1)  
    {  
      for(l=s;l>=0;l--)  
      cout<<' ';  
      for(j=k;j>0;j--)  
         cout<<"#";  
      cout<<endl;  
    }  
  return 0;  
  }  

OUTPUT:

           #
        # # #
     # # # # #
   # # # # # # #
# # # # # # # # #
   # # # # # # #
      # # # # #
        # # #
          # 

** The above solution is my own code and it may not be the optimal solution or optimal way to approach the problem. So if you have any optimal approaches feel free to paste the code as the comment below..... :) :) :)