Tuesday, 15 December 2015

Program of Diamond

                                  Diamond                              





// Black color of text in this Word file is due to black theme of my Visual Studio
             
                  // There are some more techniques to make a diamond, like combining four triangles, up and down half diamonds.
                  // I'm making my diamond by combining two 'left half' and 'write half' diamonds. I hppe u like my programe!



# include<iostream>
# include<conio.h>

using namespace std;

void main()

{                     // in this program I'm using four variables   a,b,c,d  which will be used in 2 Nested for loops.      
       for (int a = 1; a < 10; ++a)
       {                 
              for (int b = 10; b > 0; --b)
              {
                     if (b > a)

                           cout << " ";

                     else{

                           cout << "**";                   //if we put one *, half diamond will form
                     }
              }
              cout << endl;
       }
       for (int c = 10; c > 0; c--){

              for (int d = 10; d > 0; d--)
              {
                     if (c < d)

                           cout << " ";

                     else
                     {
                           cout << "**";          
                     }
              }
              cout << endl;
       }
       _getch();

}